-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Show Internal Error when rendering default Error page when a runtime error occurs on a 404 page #11131
Conversation
🦋 Changeset detectedLatest commit: 91527ab The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
} | ||
|
||
const is_runtime_error = | ||
error instanceof TypeError || error instanceof SyntaxError || error instanceof ReferenceError; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is an exhaustive list or if it'd be possible to create one. Perhaps we could go in the other direction? What the type of the error when a 404 is returned without additional error? Could we check if it's that type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iirc we don’t have a type for that right now so we'd have to create one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we get to this 500 error from here:
(await handle_error_and_jsonify(event, options, e)).message |
The 404 error happens here: https://github.com/sveltejs/kit/blob/dbbd4c7fc1ae2abef584a29a688e2247a80b9792/packages/kit/src/runtime/server/page/respond_with_error.js#L92C63-L92C63
I wondered if perhaps the error message should get handled in that line 108 in respond_with_error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we still want to change the handle_error_and_jsonify
method itself because the logic is not foolproof (e.g., an internal error can occur when the route id doesn't exist and so should be able to return the "internal error" message).
kit/packages/kit/src/runtime/server/utils.js
Line 107 in fb611ef
message: event.route.id != null ? 'Internal Error' : 'Not Found' |
These are the two places we are throwing a 404 error internally.
and the client: kit/packages/kit/src/runtime/client/client.js Line 1009 in 5eb2879
We should also update the client-side error handling that is using a similar logic as the server one we're changing now: kit/packages/kit/src/runtime/client/client.js Line 1330 in 5eb2879
|
Would something like making those 404 errors a specific type of error, and then checking that the error is that type in |
Yes, perhaps something akin to kit/packages/kit/src/runtime/control.js Lines 22 to 31 in 98e4b8f
Then we can check the object using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Fixes #10898
This change will show an error message "Internal Error" when reproducing the issue discussed above.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.