Repository navigation
fix(core): carry filter through pending emit queue - #15779
tenderdeve wants to merge 1 commit into
Conversation
When emit_filter runs while the handlers lock is held (e.g. emitting from inside an event handler) the emit is deferred onto the pending queue. The queued action dropped the filter and flushed as a plain emit, broadcasting to every target. Store the boxed filter on Pending::Emit and replay it via emit_filter. The filter now requires Send + 'static, consistent with Listeners::listen. Closes tauri-apps#15759
8c59a53 to
14cfefa
Compare
|
Sorry about the noise here — the runtime-wry monitor commits belonged to another branch and got dragged in by accident. Rebased them out, so this is now just the emit-filter change. On the If you'd rather not widen the public |
Posting chatbot responses without verifying them into a comment is to me unacceptable. It's beneath the dignity of people that care for the project to deal with this mercenary behavior. Vote to close with prejudice. |
|
Fully agree here, I'm closing this one. @tenderdeve Hey, thanks for consider contributing. I merged the last few agent PRs purely because they were better than I expected from current day LLMs and the problems need fixing. But please review all the code yourself and summarize in your own language before submitting to make it a high quality contribution. Copying something I said some time ago on Discord:
|

Closes #15759
emit_filter/emit_str_filterbroadcast to every target when the emit gets deferred onto the pending queue. That deferral happens whenever an emit runs while the handlers lock is held — most commonly emitting from inside an event handler. The queuedPending::Emitonly stored the payload, so on flush it replayed as a plain unfilteredemit().Fix: store the filter on
Pending::Emitand replay it throughemit_filteron flush.Because the queue can be flushed from a different thread than the one that deferred the emit, the stored filter has to be
Send, and boxing it into the queue requires'static. So the filter closure now requiresSend + 'static, threaded throughEmitter::emit_filter/emit_str_filterand the internal manager/listener paths. This matches the boundListeners::listenalready places on its callback. Internal callers were updated to own their captured labels; if you'd rather keep the public bound unchanged I can rework, but this mirrors the existing listener API.Added a regression test (
pending_emit_keeps_filter) that emits a filtered event from within a handler (forcing the pending path) and asserts only the targeted listener fires.