Skip to content

Report Event.Buffer leaks when running from source#298468

Merged
alexdima merged 2 commits intomainfrom
alexd/noisy-narwhal
Feb 28, 2026
Merged

Report Event.Buffer leaks when running from source#298468
alexdima merged 2 commits intomainfrom
alexd/noisy-narwhal

Conversation

@alexdima
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings February 28, 2026 17:48
@alexdima alexdima enabled auto-merge (squash) February 28, 2026 17:48
@alexdima alexdima self-assigned this Feb 28, 2026
@vs-code-engineering
Copy link
Copy Markdown
Contributor

vs-code-engineering bot commented Feb 28, 2026

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@bpasero

Matched files:

  • src/vs/base/parts/ipc/common/ipc.ts

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances Event.buffer with dev-only leak diagnostics to help identify buffered events that are never consumed when running from source (VSCODE_DEV). It updates existing call sites to provide a buffer “debug name” so warnings can be attributed to a specific buffered event.

Changes:

  • Extend Event.buffer to require a debugName and emit dev-only warnings when buffered events accumulate unconsumed (count/time thresholds).
  • Update various call sites (terminal embedder service, extension host message port, IPC channels) to pass a debugName.
  • Update Event.buffer unit tests to match the new signature.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/vs/base/common/event.ts Adds debugName parameter to Event.buffer and implements dev-only leak warning logic.
src/vs/base/parts/ipc/common/ipc.ts Updates ProxyChannel event buffering to pass the event name as debugName.
src/vs/base/test/common/event.test.ts Adjusts tests to pass a debugName to Event.buffer.
src/vs/workbench/services/terminal/common/embedderTerminalService.ts Updates buffered terminal creation event to include a debugName.
src/vs/workbench/api/common/extHostExtensionService.ts Updates buffered message-port receive event to include a debugName.
src/vs/platform/extensionManagement/common/extensionManagementIpc.ts Updates buffered extension management events to include debugNames.
src/vs/platform/mcp/common/mcpManagementIpc.ts Updates buffered MCP management events to include debugNames.
Comments suppressed due to low confidence (2)

src/vs/base/parts/ipc/common/ipc.ts:1141

  • Same as above: undefined is being passed as the _buffer argument to Event.buffer, but the implementation immediately does _buffer.slice(). This should be an empty array (or adjust the call/signature) to avoid compile/runtime failure.
						mapEventNameToEvent.set(event, Event.buffer(handler[event] as Event<unknown>, event, true, undefined, disposables));

src/vs/workbench/api/common/extHostExtensionService.ts:566

  • This Event.buffer result becomes part of the extension-facing messagePassingProtocol. Per the Event.buffer contract, public/third-party-facing buffered events should be created with a DisposableStore so the underlying DOM listener can be cleaned up when the extension is disposed. You already have extensionInternalStore in scope; consider passing it to Event.buffer(...).
						const onDidReceiveMessage = Event.buffer(Event.fromDOMEventEmitter(messagePort, 'message', e => e.data), 'onDidReceiveMessage');
						messagePort.start();
						messagePassingProtocol = {
							onDidReceiveMessage,
							// eslint-disable-next-line local/code-no-any-casts
							postMessage: messagePort.postMessage.bind(messagePort) as any
						};

Comment thread src/vs/base/parts/ipc/common/ipc.ts
Comment thread src/vs/base/common/event.ts Outdated
@alexdima alexdima merged commit a837f16 into main Feb 28, 2026
20 checks passed
@alexdima alexdima deleted the alexd/noisy-narwhal branch February 28, 2026 18:14
DonJayamanne pushed a commit that referenced this pull request Mar 2, 2026
* Report Event.Buffer leaks when running from source

* Address feedback
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Apr 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants