Skip to content

fix(electron): clean up renderer IPC listeners across preload bridge - #84

Merged
nekomeowww merged 2 commits into
mainfrom
nekomeowww/fix/electron-renderer-listener-cleanup
Sep 29, 2026
Merged

nekomeowww merged 2 commits into
mainfrom
nekomeowww/fix/electron-renderer-listener-cleanup

Conversation

@nekomeowww

@nekomeowww nekomeowww commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Dispose Electron renderer IPC listeners with the cleanup function returned by @electron-toolkit/preload's on().
  • Keep removeListener() as a fallback for a native Electron emitter.
  • Add regression tests for both transports, including repeated context creation and disposal.
  • Stabilize the WebSocket message test: reply only to its send event and wait for the actual connection event.

The preload bridge registers a callback proxy in its isolated world. Passing the renderer's callback back through removeListener() does not match that proxy, so each disposed Eventa context leaves its message and error listeners attached. The returned cleanup function closes over the registered callback and removes it correctly.

The WebSocket test server previously replied to the adapter's connection event as well as the test's explicit message. Response timing caused duplicate-message assertions or a timeout. This test-only change limits the server to the event under test.

Verification

  • The new bridge regression test failed before the fix: three disposed contexts left three eventa-message listeners.
  • On unmodified main, the WebSocket test failed in 4 of 5 isolated runs. After the test fix, it passed in 5 of 5 isolated runs.
  • pnpm test:run — 197 tests passed across 28 files.
  • pnpm typecheck, pnpm lint, and pnpm build — passed.

@nekomeowww
nekomeowww merged commit 2323e73 into main Sep 29, 2026
4 checks passed
@nekomeowww
nekomeowww deleted the nekomeowww/fix/electron-renderer-listener-cleanup branch September 29, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant