-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Labels
Description
Describe the bug
I am wondering if there's a particular reason getRequestEvent is not available in HandleServerError hook? I would expect it to work here along side the other server function and handles.
Can only read the current request event inside functions invoked during `handle`, such as server `load` functions, actions, and server endpoints.
Thanks 🙌
Reproduction
Example in hooks.server.js. Visit invalid page e.g. /invalid.
https://stackblitz.com/edit/sveltejs-kit-template-default-wwnmlhej?file=src%2Fhooks.server.js
Logs
Error: Can only read the current request event inside functions invoked during `handle`, such as server `load` functions, actions, and server endpoints.
at getRequestEvent (/home/projects/sveltejs-kit-template-default-wwnmlhej/node_modules/@sveltejs/kit/src/runtime/app/server/event.js:37:9)
at Object.handleError (/home/projects/sveltejs-kit-template-default-wwnmlhej/src/hooks.server.js:7:67)
at handle_error_and_jsonify (/home/projects/sveltejs-kit-template-default-wwnmlhej/node_modules/@sveltejs/kit/src/runtime/server/utils.js:73:30)
at respond_with_error (/home/projects/sveltejs-kit-template-default-wwnmlhej/node_modules/@sveltejs/kit/src/runtime/server/page/respond_with_error.js:97:67)
at async resolve (/home/projects/sveltejs-kit-template-default-wwnmlhej/node_modules/@sveltejs/kit/src/runtime/server/respond.js:442:16)
at async respond (/home/projects/sveltejs-kit-template-default-wwnmlhej/node_modules/@sveltejs/kit/src/runtime/server/respond.js:261:22)
at async eval (file:///home/projects/sveltejs-kit-template-default-wwnmlhej/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:564:22)System Info
Latest versions, see Stackblitz aboveSeverity
annoyance
Additional Information
No response