-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
Milestone
Description
Describe the bug
If the load function of a page module returns an object with the redirect property set but the status property is undefined, sveltekit generates an error to the dev to let them know the mistake. However, this error does not flow into the handleError hook where the dev is likely to have set up error logging.
Reproduction
- Clone https://github.com/moatra/sveltekit-redirect-error-handler
npm installnpm run dev- Load
http://localhost:3000/err_genin a new browser tab.
- Observe the logs (first block in Logs). The error appears in both
handleErrorand the__error.sveltecomponent.
- Load
http://localhost:3000/bad_redirectin a new browser tab (or otherwise force SSR)
- Observe the logs (second block in Logs). The error only appers in the
__error.sveltecomponent.
Logs
Visiting /err_gen:
handleError() called for /err_gen Error: throwing an error from err_gen.svelte
at load (err_gen.svelte:3:18)
at load_node (file:///home/thomas/Projects/sveltekit-redirect-error-handler/node_modules/@sveltejs/kit/dist/chunks/index.js:1133:30)
at respond$1 (file:///home/thomas/Projects/sveltekit-redirect-error-handler/node_modules/@sveltejs/kit/dist/chunks/index.js:1347:21)
at async render_page (file:///home/thomas/Projects/sveltekit-redirect-error-handler/node_modules/@sveltejs/kit/dist/chunks/index.js:1538:19)
at async resolve (file:///home/thomas/Projects/sveltekit-redirect-error-handler/node_modules/@sveltejs/kit/dist/chunks/index.js:1863:10)
at async Object.handle (//home/thomas/Projects/sveltekit-redirect-error-handler/src/hooks:8:19)
at async respond (file:///home/thomas/Projects/sveltekit-redirect-error-handler/node_modules/@sveltejs/kit/dist/chunks/index.js:1829:10)
at async file:///home/thomas/Projects/sveltekit-redirect-error-handler/node_modules/@sveltejs/kit/dist/chunks/index.js:2157:24
The __error.svelte component saw an error: Error: throwing an error from err_gen.svelte
at load (err_gen.svelte:3:18)
at load_node (file:///home/thomas/Projects/sveltekit-redirect-error-handler/node_modules/@sveltejs/kit/dist/chunks/index.js:1133:30)
at respond$1 (file:///home/thomas/Projects/sveltekit-redirect-error-handler/node_modules/@sveltejs/kit/dist/chunks/index.js:1347:21)
at async render_page (file:///home/thomas/Projects/sveltekit-redirect-error-handler/node_modules/@sveltejs/kit/dist/chunks/index.js:1538:19)
at async resolve (file:///home/thomas/Projects/sveltekit-redirect-error-handler/node_modules/@sveltejs/kit/dist/chunks/index.js:1863:10)
at async Object.handle (//home/thomas/Projects/sveltekit-redirect-error-handler/src/hooks:8:19)
at async respond (file:///home/thomas/Projects/sveltekit-redirect-error-handler/node_modules/@sveltejs/kit/dist/chunks/index.js:1829:10)
at async file:///home/thomas/Projects/sveltekit-redirect-error-handler/node_modules/@sveltejs/kit/dist/chunks/index.js:2157:24
Visiting /bad_redirect:
The __error.svelte component saw an error: Error: "redirect" property returned from load() must be accompanied by a 3xx status code
at normalize (file:///home/thomas/Projects/sveltekit-redirect-error-handler/node_modules/@sveltejs/kit/dist/chunks/index.js:832:12)
at load_node (file:///home/thomas/Projects/sveltekit-redirect-error-handler/node_modules/@sveltejs/kit/dist/chunks/index.js:1148:11)
at async respond$1 (file:///home/thomas/Projects/sveltekit-redirect-error-handler/node_modules/@sveltejs/kit/dist/chunks/index.js:1347:15)
at async render_page (file:///home/thomas/Projects/sveltekit-redirect-error-handler/node_modules/@sveltejs/kit/dist/chunks/index.js:1538:19)
at async resolve (file:///home/thomas/Projects/sveltekit-redirect-error-handler/node_modules/@sveltejs/kit/dist/chunks/index.js:1863:10)
at async Object.handle (//home/thomas/Projects/sveltekit-redirect-error-handler/src/hooks.js:12:19)
at async respond (file:///home/thomas/Projects/sveltekit-redirect-error-handler/node_modules/@sveltejs/kit/dist/chunks/index.js:1829:10)
at async file:///home/thomas/Projects/sveltekit-redirect-error-handler/node_modules/@sveltejs/kit/dist/chunks/index.js:2157:24
System Info
❯ npx envinfo --system --binaries --browsers --npmPackages "{svelte,@sveltejs/*,vite}"
System:
OS: Linux 5.15 Fedora Linux 35 (Workstation Edition)
CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
Memory: 23.68 GB / 31.33 GB
Container: Yes
Shell: 5.1.8 - /bin/bash
Binaries:
Node: 16.13.0 - /usr/bin/node
npm: 8.1.0 - /usr/bin/npm
Browsers:
Firefox: 96.0
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.11
@sveltejs/kit: next => 1.0.0-next.232
svelte: ^3.44.0 => 3.46.2Severity
annoyance
Additional Information
No response