fix(preload): one shared ipcRenderer listener for per-pane channels - #1039
Merged
Merged
Conversation
#1015. Against a real EventEmitter as ipcRenderer, 12 goal-loop:changed or dictation:stream-transcript subscribers must create one listener, deliver every event to all of them, remove the listener with the last unsubscribe, and emit no MaxListeners warning. A subscriber that throws must not starve the others. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
#1015. Every mounted GoalLoopPane and composer subscribed its own ipcRenderer listener, so eleven panes crossed Node's MaxListeners of 10 and the dev app warned "Possible EventEmitter memory leak" at every startup. It was not a leak, but a permanent false alarm hides the next real one, and raising the limit would silence that alarm. subscribeShared keeps one relay listener per channel, fanned out to a set of subscribers. The relay is removed with the last subscriber, and each subscriber is isolated from another's throw. goal-loop:changed and dictation:stream-transcript use it. LSP diagnostics keeps its permanent listener on purpose (see lsp.ts: code blocks mount and unmount while scrolling). Closes #1015 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… check real From the #1039 review (CHANGES REQUESTED): - MEDIUM: record-session:started and record-session:stopping are also subscribed per rendered pane (every Feed mounts a RenderShapeCaptureProvider), so 11 panes still warned at startup. tldr:changed and goal:changed do the same while a peek is up. All four use subscribeShared, and the test covers all six channels. - LOW: Node emits MaxListenersExceededWarning on process.nextTick, so the test's warning spy must outlive a tick. Otherwise the check could never fail. - NIT: the comment now says why LSP diagnostics keeps its own permanent listener. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Owner
Author
|
Review (CHANGES REQUESTED) addressed in
preload: 15/15, and tsc is clean. |
Juliusolsson05
added a commit
that referenced
this pull request
Sep 19, 2026
…1047 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1015.
Why
The dev app warned at every startup:
MaxListenersExceededWarning: 11 goal-loop:changed listeners added to [IpcRenderer](and the same fordictation:stream-transcript).It is not a leak. Every mounted
GoalLoopPaneand composer subscribes once and cleans up. But each subscription was its ownipcRendererlistener, so 11 panes crossed Node's default of 10. A permanent false alarm hides the next real leak. RaisingMaxListenerswould silence exactly that alarm.Change
subscribeShared(channel, cb)inpreload/api/ipc.ts:goal-loop:changedanddictation:stream-transcriptuse it.Tests
src/preload/api/sharedListeners.test.tsuses a realEventEmitterasipcRenderer, for both channels:All four cases fail on main. The goal-loop and dictation renderer suites pass (18), and
npx tsc -bis clean.🤖 Generated with Claude Code