svelte icon indicating copy to clipboard operation
svelte copied to clipboard

fix: add a warning when the misuse of `reset` in an `error:boundary` causes an error to be thrown when flushing the boundary content

Open raythurnvoid opened this issue 5 months ago • 3 comments

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

  • [x] 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://github.com/sveltejs/rfcs
  • [x] Prefix your PR title with feat:, fix:, chore:, or docs:.
  • [x] This message body should clearly illustrate what problems it solves.
  • [x] Ideally, include a test that fails without this PR but passes with it.
  • [x] If this PR changes code within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • [x] Run the tests with pnpm test and lint the project with pnpm lint

raythurnvoid avatar Jun 15 '25 19:06 raythurnvoid

Preview: https://svelte-dev-git-preview-svelte-16171-svelte.vercel.app/

svelte-docs-bot[bot] avatar Jun 15 '25 19:06 svelte-docs-bot[bot]

🦋 Changeset detected

Latest commit: 8891015e0073cfaf689c9b236a6ab4d164e98832

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

This PR includes changesets to release 1 package
Name Type
svelte Patch

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

changeset-bot[bot] avatar Jun 15 '25 19:06 changeset-bot[bot]

Playground

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

github-actions[bot] avatar Jun 15 '25 19:06 github-actions[bot]

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

Rich-Harris avatar Jun 18 '25 13:06 Rich-Harris