Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow events to continue propagating following an error #11263

Merged
merged 3 commits into from
Apr 22, 2024
Merged

Conversation

Rich-Harris
Copy link
Member

@Rich-Harris Rich-Harris commented Apr 20, 2024

This is an alternative to #11239. It's technically a breaking change, but I think the behaviour is much more reasonable than that of Svelte 4: if an event handler throws, propagation continues.

Fixes #8403. Demo

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.

Tests and linting

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

Copy link

changeset-bot bot commented Apr 20, 2024

🦋 Changeset detected

Latest commit: 2574966

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

@dummdidumm
Copy link
Member

It's weird that the error is thrown only after all the events, and the last instead of the first error is thrown. Not sure which behavior is better, arguably two errors are even more of an edge case though.

@Rich-Harris
Copy link
Member Author

It's not totally ideal, but we've gone from 'you only get one error' to 'you only get one error' — the fact that it's the last error rather than the first doesn't really make a colossal difference in my view. Similarly I don't think it matters that the error only 'happens' after the handlers have run, as long as the handlers themselves run in the right order. I'd 100% rather have this behaviour than the status quo

@Rich-Harris Rich-Harris merged commit 521d124 into main Apr 22, 2024
8 checks passed
@Rich-Harris Rich-Harris deleted the gh-8403 branch April 22, 2024 11:51
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.

Inconsistent exception handling with multiple event handlers
2 participants