Skip to content

fix: call all event handlers even if an exception occurs in one #8443

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

Closed
wants to merge 10 commits into from

Conversation

adiguba
Copy link
Contributor

@adiguba adiguba commented Apr 1, 2023

Error in Svelte event dispatcher is inconsistant with the browser event handling.

I think that Svelte should mimic the browser event handling : if an error occurs on an event-handler, it should be stopped, but it should not impact the others event-handlers.

Fixes #8403

Note that I try to write an unit-test, but it fails because of the exception on the handler, and I don't know how to ignore that.

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

  • Run the tests with npm test and lint the project with npm run lint

@vercel
Copy link

vercel bot commented Apr 1, 2023

@adiguba is attempting to deploy a commit to the Svelte Team on Vercel.

A member of the Team first needs to authorize it.

@benmccann benmccann changed the title fix: 8403 - Inconsistent exception handling with multiple event handlers fix: call all event handlers even if an exception occurs in one Apr 2, 2023
fn.call(source, event);
} catch (err) {
// @ts-ignore
if (window.reportError) {
Copy link
Member

Choose a reason for hiding this comment

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

question for more knowledgeable reviewers: will this file be called during ssr? if so, we probably need to fix this reference to window. also note that reportError is not yet supported in Node

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I miss that component events can be triggered in SSR !
Don't know how to handle this correctly...

@dummdidumm dummdidumm added this to the one day milestone Apr 11, 2023
@Rich-Harris
Copy link
Member

Closing as we're no longer adding stuff to Svelte 4, but updated #8403 for Svelte 5

@Rich-Harris Rich-Harris closed this Apr 1, 2024
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
4 participants