Remote `query` with `redirect` produce 500 `undefined` error
Describe the bug
Route with remote query which has redirect results in 500 undefined error.
<script lang="ts">
import { verifyUser } from "$lib/remote/auth.remote";
await verifyUser()
</script>
<p>protected</p>
import { query } from "$app/server";
import { redirect } from "@sveltejs/kit";
export const verifyUser = query(() => {
redirect(307, '/')
})
Error:
Reproduction
https://github.com/vladshcherbin/sveltekit-redirect-error
Logs
System Info
System:
OS: macOS 26.0
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.0.1
npm: 11.3.0
pnpm: 10.20.0
Browsers:
Chrome: 142.0.7444.60
Safari: 26.0
npmPackages:
@sveltejs/adapter-auto: ^7.0.0 => 7.0.0
@sveltejs/kit: ^2.48.4 => 2.48.4
@sveltejs/vite-plugin-svelte: ^6.2.1 => 6.2.1
svelte: ^5.43.3 => 5.43.3
vite: ^7.1.10 => 7.1.12
Severity
serious, but I can work around it
Additional Information
There is no error if query is wrapped inside <svelte:boundary>
https://github.com/sveltejs/svelte/issues/17108 shows error difference with different svelte versions
I have the same issue
I think what is probably the same root cause can also crash the SK server. If your redirecting query is wrapped in a rune like $state or $derived then during SSR the server will crash:
[500] GET /page2
undefined
UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "[object Object]".
at _0xe48d04 (https://qo5ip4we0aj4vrkeetv8swp3pbyxe1-fmt4.w-corp-staticblitz.com/blitz.cf284e50.js:31:22445)
at UnhandledPromiseRejection (node:internal/process/promises:193:1037)
at throwUnhandledRejectionsMode (node:internal/process/promises:193:4316)
at processPromiseRejections (node:internal/process/promises:193:5015)
at processTicksAndRejections (node:internal/process/task_queues:196:1218)
at <anonymous> (https://qo5ip4we0aj4vrkeetv8swp3pbyxe1-fmt4.w-corp-staticblitz.com/blitz.cf284e50.js:31:545396) {
code: 'ERR_UNHANDLED_REJECTION'
}
Reproduction: https://www.sveltelab.dev/x078fj7c88vkn20?files=.%2Fsrc%2Froutes%2F%2Blayout.svelte%2C.%2Fsrc%2Froutes%2F%2Bpage.ts%2C.%2Fsrc%2Froutes%2Fpage2%2Fpage2.remote.ts
Click "Page 2" to trigger the error. Note that CSR is disabled globally to demonstrate this issue.