Skip to content

query.batch receiving GET requests with X-Sveltekit-Pathname header #15314

@harshmandan

Description

@harshmandan

Describe the bug

We're seeing errors on our sentry dashboard:
'query.batch' functions must be invoked via POST request, not GET

The sentry error has headers set: X-Sveltekit-Pathname and other SK headers which are only set by remote_request() in the client code

More details:

X-Sveltekit-Pathname: /app/home
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Referer: https://[domain]/app/home

This is not a widespread issue total reported issues by sentry <1000.

Question:

Is there a known code path where a query.batch function could be invoked via remote_request() (GET) instead of the query_batch client code (POST)? The presence of X-Sveltekit-Pathname header suggests the SvelteKit client is making these requests, but through the wrong code path.

How we use the remote function:

    // Called in reactive context
    $: allItems = items.map(item => ({
      videoUrl: getSignedUrl(item.id),
      // ...
    }))

The remote function:

export const getSignedUrl = query.batch(z.string(), async (keys) => {
  const results = await Promise.allSettled(
    keys.map(async (key) => {
      const { video } = await video.getUrl(key)
      return video.url
    }
  )
  return result.value
  })

Reproduction

I am not able to reproduce this

Logs

No Logs

System Info

"@sveltejs/kit": "2.50.2"

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions