Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork4.6k
fix: add a warning when the misuse ofreset
in anerror:boundary
causes an error to be thrown when flushing the boundary content#16171
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation
610b455
to7490fbe
Comparechangeset-botbot commentedJun 15, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
🦋 Changeset detectedLatest commit:8891015 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 |
|
…s an error to be thrown when flushing the boundary content
… are fired during template effects flush
7490fbe
to28b0310
CompareThank you. The behaviour of boundaries seems just wrong here — an error that occurs during reset shouldnot escape the current boundary; that's deeply unhelpful. Surprised that never surfaced until now. Working on it locally, will push to this PR. Checking that |
}); | ||
}; | ||
varprevious_reaction=active_reaction; | ||
try{ | ||
set_active_reaction(null); | ||
calling_on_error=true; | ||
onerror?.(error,reset); |
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.
@Rich-Harris People might want to auto-fix the state of the application inside the onerror for instance they might decide to show an error snackbar and reset a form without any confirmation from the user
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 won't work — the update is still in progress and everything gets torn. Thesvelte_boundary_reset_onerror
message has an example of fixing it by waiting for atick()
before callingreset()
9e1e713
intosveltejs:mainUh oh!
There was an error while loading.Please reload this page.
Add warning message when situations like#16134 happen.
The user reporting the issue is misusing
reset
by calling it before the problematic template is rendered,reset
"pauses" the error boundary and this allows the error to bubble up.This adds a warning message when this happens instructing the user to fix the problematic app state before calling
reset
or to usereset
when the user clicks a button in the fallback UI.Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.packages/svelte/src
, add a changeset (npx changeset
).Tests and linting
pnpm test
and lint the project withpnpm lint