-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
breaking changebugSomething isn't workingSomething isn't workingerror handlingp1-importantSvelteKit cannot be used by a large number of people, basic functionality is missing, etc.SvelteKit cannot be used by a large number of people, basic functionality is missing, etc.
Milestone
Description
Describe the bug
In hooks.js I wrap the await resolve(event)
in a try/catch in order to do things like rollback a DB transaction.
This works fine when the exception is thrown from the shadow endpoint but the exception fails to bubble up to handle()
when the same page is rendered on the server.
Reproduction
// hooks.js
export const handle = async ({ event, resolve }) => {
let response
try {
response = await resolve(event);
} catch (err) {
console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
console.log(err)
throw err
}
}
// routes/endpoint.js
export const get = async () => {
throw new Error("I should see some @'s")
}
Logs
From a full page load (SSR)
I should see some @'s!
Error: I should see some @'s!
at get (/private/tmp/my-app/src/routes/todos/index.ts:2:10)
at load_shadow_data (file:///private/tmp/my-app/.svelte-kit/runtime/server/index.js:2530:25)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async load_node (file:///private/tmp/my-app/.svelte-kit/runtime/server/index.js:2127:5)
at async respond$1 (file:///private/tmp/my-app/.svelte-kit/runtime/server/index.js:2804:15)
at async resolve (file:///private/tmp/my-app/.svelte-kit/runtime/server/index.js:3309:11)
at async Object.handle (/private/tmp/my-app/src/hooks.ts:5:13)
at async respond (file:///private/tmp/my-app/.svelte-kit/runtime/server/index.js:3253:20)
at async file:///private/tmp/my-app/node_modules/@sveltejs/kit/dist/chunks/index.js:294:24
From a shadow endpoint fetch (__data.json
)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Error: I should see some @'s!
at get (/private/tmp/my-app/src/routes/todos/index.ts:4:9)
at render_endpoint (file:///private/tmp/my-app/.svelte-kit/runtime/server/index.js:171:25)
at resolve (file:///private/tmp/my-app/.svelte-kit/runtime/server/index.js:3286:24)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.handle (//private/tmp/my-app/src/hooks.ts:6:16)
at async respond (file:///private/tmp/my-app/.svelte-kit/runtime/server/index.js:3253:20)
at async file:///private/tmp/my-app/node_modules/@sveltejs/kit/dist/chunks/index.js:294:24
System Info
System:
OS: macOS 12.2.1
CPU: (10) arm64 Apple M1 Pro
Memory: 240.88 MB / 32.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 17.6.0 - /opt/homebrew/bin/node
Yarn: 1.22.18 - ~/.yarn/bin/yarn
npm: 8.5.2 - /opt/homebrew/bin/npm
Browsers:
Chrome: 100.0.4896.127
Safari: 15.3
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.40
@sveltejs/kit: next => 1.0.0-next.324
svelte: ^3.46.0 => 3.48.0
Severity
serious, but I can work around it
Additional Information
I'm not 100% sure how to work around it...
Metadata
Metadata
Assignees
Labels
breaking changebugSomething isn't workingSomething isn't workingerror handlingp1-importantSvelteKit cannot be used by a large number of people, basic functionality is missing, etc.SvelteKit cannot be used by a large number of people, basic functionality is missing, etc.