fix: don't invoke handleError for server-handled errors during preload#16474
Open
ondraulehla wants to merge 1 commit into
Open
fix: don't invoke handleError for server-handled errors during preload#16474ondraulehla wants to merge 1 commit into
ondraulehla wants to merge 1 commit into
Conversation
When a preloaded route's server load throws error(), the branch loader's preload path returned before the server_data_nodes guard, so the client handleError hook ran with the raw server error node and status 500. Error-reporting integrations that filter 4xx by status (e.g. Sentry) therefore reported ordinary server-rendered 404s as client 500s whenever a link was hovered instead of clicked. Compute the error and status through the same guard as normal navigation before the preload return, so server-handled errors skip the client hook on the preload path too. Fixes sveltejs#16456
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/f555c519f298dca35ab226a8fbc3f3f94de71c9aOpen in Note This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed. |
🦋 Changeset detectedLatest commit: f555c51 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #16456
When a preloaded route's server
loadthrowserror(404), the clienthandleErrorhook runs with the raw server error node andstatus: 500.On normal navigation the branch loader skips the client hook for errors
already handled on the server, but the preload path returns before that
guard is reached. As the issue describes, integrations that filter out
4xx by status (like Sentry) then report ordinary server 404s as client
500s, just because a link was hovered instead of clicked.
I moved the error and status computation in front of the preload return,
so preloads go through the same guard as normal navigation. The
updated.check()reload logic stays out of the preload path, same asbefore. The new test preloads a route whose server load throws
error(404)viapreloadData()and asserts the hook is not invoked —it fails without the fix and passes with it, in both dev and build modes.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test(basics suite) andpnpm lintpass;pnpm checkfails on upstream main itself (pre-existing, unrelated)Changesets
@sveltejs/kitpatch,fix:prefix)Edits