Skip to content

Conversation

elliott-with-the-longest-name-on-github
Copy link
Contributor

I'm totally baffled about this one right now. Apparently, errors bubble in the wrong direction, but only in some circumstances. If I inline test.svelte into main.svelte by moving the template inside of the error boundary (such that both boundaries are in main.svelte) it succeeds. It appears to have something to do with the fact that the outer boundary then has a component rendered inside of it which then contains a boundary. This makes me think it's some sort of effect scheduling issue... but I can't pin it down.

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://github.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

Copy link

changeset-bot bot commented Sep 9, 2025

⚠️ No Changeset found

Latest commit: 602b885

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

github-actions bot commented Sep 9, 2025

Playground

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

btn?.click();
flushSync();

assert.deepEqual(logs, ['error caught 1', 'error caught 2']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is behaving correctly, the assertion is wrong (and nonsensical! where did error caught 2 come from?). test is outside the error caught 1 boundary, and so the only thing that should get logged is error caught root:

Suggested change
assert.deepEqual(logs, ['error caught 1', 'error caught 2']);
assert.deepEqual(logs, ['error caught root']);

The mystery here is why error-boundary-19 appears to behave differently, despite #16091

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured out at least part of the mystery: when update_reaction(derived) inside execute_derived, the finally block, which undoes set_active_effect(get_derived_parent_effect(derived)), happens before the error is handled

@Rich-Harris Rich-Harris marked this pull request as draft September 10, 2025 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants