Report Event.Buffer leaks when running from source#298468
Merged
Conversation
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @bpaseroMatched files:
|
Contributor
There was a problem hiding this comment.
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.bufferto require adebugNameand 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.bufferunit 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:
undefinedis being passed as the_bufferargument toEvent.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.bufferresult becomes part of the extension-facingmessagePassingProtocol. Per theEvent.buffercontract, public/third-party-facing buffered events should be created with aDisposableStoreso the underlying DOM listener can be cleaned up when the extension is disposed. You already haveextensionInternalStorein scope; consider passing it toEvent.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
};
dmitrivMS
approved these changes
Feb 28, 2026
DonJayamanne
pushed a commit
that referenced
this pull request
Mar 2, 2026
* Report Event.Buffer leaks when running from source * Address feedback
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
No description provided.