fix(sveltekit): Handle SvelteKit 3 error kinds in handleErrorWithSentry - #23651
Merged
Conversation
SvelteKit 3 changed the `handleError` input to `{ kind, error, event }`: `status` moved onto
the error, and expected errors thrown with `error(...)` now reach the hook too. Reading the old
`status` meant capturing framework 404s and every intentional `error(400, …)` on Kit 3, plus a
SvelteKit deprecation warning per error in dev.
Branch on `kind` and apply the SDK's usual rule: capture unexpected errors always, app and
framework errors only at 5xx, skip validation errors. Declare the hook types structurally, since
Kit 3 moved them to `@sveltejs/kit/hooks`, which doesn't resolve on Kit 2.
SvelteKit 1.x/2.x behaviour is unchanged.
Fixes #23650
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Member
Author
|
bugbot run |
Contributor
size-limit report 📦
|
Explain why the wrapper's double casts can't be narrowed, and replace the timeout race in the 4xx e2e test with a concrete signal, per the repo's testing guidance. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Member
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 6bf4f27. Configure here.
chargome
marked this pull request as ready for review
August 27, 2026 08:22
chargome
requested review from
Lms24,
nicohrubec and
s1gr1d
and removed request for
a team
August 27, 2026 08:22
nicohrubec
approved these changes
Aug 27, 2026
nicohrubec
left a comment
Member
There was a problem hiding this comment.
lgtm, just two minor style notes/questions
s1gr1d
reviewed
Aug 27, 2026
Model the `handleError` input as a discriminated union, so `status` and `message` can't be read on a SvelteKit 3 input where they only exist as deprecated dev-only getters - the type system now enforces what a comment used to. Skip validation errors on their `kind` rather than relying on SvelteKit always giving them a 400, share the capture decision between server and client, and rename the legacy check to say what it actually does. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
SvelteKit 3 changed the
handleErrorinput to{ kind, error, event }-statusmoved onto the error, and expected errors thrown witherror(...)now reach the hook too. Reading the oldstatusmeant capturing framework 404s and every intentionalerror(400, …)on Kit 3, plus a SvelteKit deprecation warning per error in dev.The wrapper now branches on
kindand applies the SDK's usual rule: capture unexpected errors always, app and framework errors only at 5xx, skip validation errors. Hook types are declared structurally because Kit 3 moved them to@sveltejs/kit/hooks, which doesn't resolve on Kit 2. SvelteKit 1.x/2.x behaviour is unchanged.Fixes #23650