What happened?
Description
In react/features/external-api/middleware.ts, the SET_CONFIG handler registers an anonymous arrow function for the unload (or beforeunload) event:
https://github.com/jitsi/jitsi-meet/blob/master/react/features/external-api/middleware.ts#L247
Every time SET_CONFIG is dispatched (such as during iframe embeds or long-lived SPA sessions that update config dynamically), a brand new, anonymous event listener is bound to the window.
Because it's an anonymous function without a stable reference, these listeners accumulate and are never deduplicated or removed.
Impact
When the window is eventually closed or unloaded, this triggers duplicate side effects for each accumulated listener:
notifyConferenceLeft is fired redundantly.
APP.API.dispose() and getJitsiMeetTransport().dispose() are called multiple times unnecessarily.
Proposed Solution
Hoist the event handler and event name to module-scoped variables. Within the SET_CONFIG case, check if the previous listener exists and remove it via window.removeEventListener() before registering the new one.
I am opening a PR with the fix shortly.
Platform
Browser / app / sdk version
Latest (master / meet.jit.si)
Relevant log output
There are no direct crash logs. However, if using the iFrame API or a long-lived session where SET_CONFIG is updated, checking `getEventListeners(window).unload` in the devtools console will show multiple anonymous listeners accumulating. Upon closing the window, the Network Tab will show duplicate requests for `notifyConferenceLeft`.
Reproducibility
More details?
No response
What happened?
Description
In
react/features/external-api/middleware.ts, theSET_CONFIGhandler registers an anonymous arrow function for theunload(orbeforeunload) event:https://github.com/jitsi/jitsi-meet/blob/master/react/features/external-api/middleware.ts#L247
Every time
SET_CONFIGis dispatched (such as during iframe embeds or long-lived SPA sessions that update config dynamically), a brand new, anonymous event listener is bound to thewindow.Because it's an anonymous function without a stable reference, these listeners accumulate and are never deduplicated or removed.
Impact
When the window is eventually closed or unloaded, this triggers duplicate side effects for each accumulated listener:
notifyConferenceLeftis fired redundantly.APP.API.dispose()andgetJitsiMeetTransport().dispose()are called multiple times unnecessarily.Proposed Solution
Hoist the event handler and event name to module-scoped variables. Within the
SET_CONFIGcase, check if the previous listener exists and remove it viawindow.removeEventListener()before registering the new one.I am opening a PR with the fix shortly.
Platform
Browser / app / sdk version
Latest (master / meet.jit.si)
Relevant log output
Reproducibility
More details?
No response