Skip to content

fix: double event processing in Firefox (#16522) #16527

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

Merged
merged 2 commits into from
Jul 31, 2025

Conversation

laszlokorte
Copy link
Contributor

Firefox seems to garbage collect event objects during event propagation if no global/shared reference to the event object is kept between multiple event handlers. That discards the __root marker set on the event object to early, leading to duplicate processing.

I am not sure what is a good way to test this.

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 (Events firing multiple times when toggling large DOM change #16522)
  • 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

Firefox seems to garbage collect event objects during event propagation if no global reference to the event object is kept.
That discards the __root marker set on the event object to early,
leading to duplicate processing.
Copy link

changeset-bot bot commented Jul 30, 2025

🦋 Changeset detected

Latest commit: 4edbbfc

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

Copy link
Contributor

Playground

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

@Ocean-OS
Copy link
Member

Thanks!

@Ocean-OS Ocean-OS merged commit a91e015 into sveltejs:main Jul 31, 2025
11 checks passed
@github-actions github-actions bot mentioned this pull request Jul 31, 2025
@7nik
Copy link
Contributor

7nik commented Jul 31, 2025

Is it me, or the fix doesn't work at all? I guess last_propagated_event is treeshaked because it is never read.

@laszlokorte
Copy link
Contributor Author

Oh, it worked for me locally but you are right that it seems to be treeshaken

@plgingras88
Copy link
Contributor

plgingras88 commented Aug 4, 2025

fyi - Mozilla acknowledged the severity of the bug in Firefox and prepared a PR to fix it in the current stable release. It was initially classified as a normal (S3) issue to be addressed in the next version, but after realizing it was breaking Svelte and directly impacting our business app with a concrete example, they raised the priority to S2 and work to deliver a fix for the current version.

Meanwhile, thanks to svelte amazing team for being that reactive with some magic work-arounds that made the trick for us !

https://bugzilla.mozilla.org/show_bug.cgi?id=1980081

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.

4 participants