Skip to content

fix(core): guard event unlisten script when listener entry is missing - #15800

Merged
amrbashir merged 2 commits into
tauri-apps:devfrom
lazerg:fix/issue-15799-guard-unlisten-missing-entry
Sep 7, 2026
Merged

amrbashir merged 2 commits into
tauri-apps:devfrom
lazerg:fix/issue-15799-guard-unlisten-missing-entry

Conversation

@lazerg

@lazerg lazerg commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

listen() resolves once Rust answers its invoke, but the webview registry entry is written by a separate, later eval, so the returned unlisten function can run before that entry exists. In that window the generated unlisten script read handlerId off an undefined entry and threw, and because that throw happens before _unlisten sends the backend plugin:event|unlisten, the listener stayed registered and kept firing. This checks the entry is present before reading it, the same guard the event delivery script already uses.

Fixes #15799

@lazerg
lazerg requested a review from a team as a code owner July 30, 2026 09:53
@Legend-Master Legend-Master added the status: needs repro This issue needs to a minimal complete and reproducible example label Aug 10, 2026
@lazerg

lazerg commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Hey @Legend-Master, just checking in on this fix. Let me know if you would like any changes.

Comment thread crates/tauri/src/event/mod.rs Outdated
assert_eq!("only alphanumeric, '-', '/', ':', '_' permitted for event names: \"some\\r illegal event name\"", s);
}

#[test]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is a useless test, let's remove

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed in 6a8060e.

@amrbashir
amrbashir merged commit 406feea into tauri-apps:dev Sep 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: needs repro This issue needs to a minimal complete and reproducible example

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unlisten throws and leaks the listener when called before the registration eval lands (listeners[eventId] undefined)

3 participants