Conversation
The webagg frontend assigned an onunload handler to the rendering Image element, but no unload event exists on HTMLImageElement or any of its ancestors, so the handler was never invoked by any browser. Websocket cleanup on page teardown is already handled by the browser closing the connection and the server-side on_close path.
|
Thank you for opening your first PR into Matplotlib! If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process. You can also join us on discourse chat for real-time discussion. For details on testing, writing docs, and our review process, please see the developer guide. We strive to be a welcoming and open project. Please follow our Code of Conduct. |
|
Closing this PR and blocking the account for one week per our AI policy. The account in question has opened several PRs across multiple repositories in a rapid fashion. Additionally, AgentScan detected automated activity. |
Summary
The webagg frontend (
lib/matplotlib/backends/web_backend/js/mpl.js) assigned anonunloadhandler to the renderingImageelement that closed the websocket. Nounloadevent exists onHTMLImageElementor any of its ancestors (HTMLElement,Element,Node) — per the MDN docs it only exists on the globalWindowinterface. The assignment was a plain expando property that no browser ever invoked, so the handler has been dead code since it was introduced.Removing it outright (rather than migrating to
pagehide/visibilitychange) is behavior-neutral because the real cleanup paths are untouched:WebSocketHandler.on_close→FigureManagerWebAgg.remove_web_socket(backend_webagg.py).comm.on_closein backend_nbagg.py), independent of this handler.Testing
node --check js/mpl.js— syntax OKgrep -c onunload js/*.js— 0 occurrences remaininstall_subdir('js'), served viaStaticFileHandler), so no build step appliesFixes #32393