Conversation

raythurnvoid

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 use reset when the user clicks a button in the fallback UI.

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.
  • If this PR changes code within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

@svelte-docs-bot

@raythurnvoidraythurnvoid force-pushed the fix/@sveltejs/svelte/16134 branch from 610b455 to 7490fbe Compare June 15, 2025 19:30
@changeset-botchangeset-bot

🦋 Changeset detected

Latest commit: f686128

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
NameType
svelte

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

@github-actionsGitHub Actions

Playground

pnpm add https://pkg.pr.new/svelte@16171

@raythurnvoidraythurnvoid force-pushed the fix/@sveltejs/svelte/16134 branch from 7490fbe to 28b0310 Compare June 15, 2025 19:37
@Rich-Harris

Thank you. The behaviour of boundaries seems just wrong here — an error that occurs during reset should not 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 reset isn't called during onerror is a good call though, will keep that part of it

});
};

var previous_reaction = active_reaction;

try {
set_active_reaction(null);
calling_on_error = true;
onerror?.(error, reset);
Copy link
Contributor Author

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

Copy link
Member

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. The svelte_boundary_reset_onerror message has an example of fixing it by waiting for a tick() before calling reset()

Sign up for free to join this conversation on . Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.