Skip to content

Fix copilot code reference output channel race - #342272

Merged
Dmitriy Vasyura (dmitrivMS) merged 2 commits into
microsoft:mainfrom
RReverser:fix/copilot-code-reference-output-channel-race
Oct 27, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 2 commits into
microsoft:mainfrom
RReverser:fix/copilot-code-reference-output-channel-race

Conversation

@RReverser

Copy link
Copy Markdown
Contributor

The code-reference logger created its output channel eagerly during Copilot initialization. When the first authentication token reported that code quoting was disabled, the logger immediately disposed that channel while VS Code could still be registering it asynchronously. The late registration then added resources to an already-disposed store and emitted leak warnings. This is visible when Copilot initializes for an agent request in a profile where code quoting is disabled, including signed-out test profiles.

Create the channel only when code quoting is enabled or a citation is actually logged, and cover the lazy lifecycle with a regression test.

The code-reference logger created its output channel eagerly during Copilot initialization. When the first authentication token reported that code quoting was disabled, the logger immediately disposed that channel while VS Code could still be registering it asynchronously. The late registration then added resources to an already-disposed store and emitted leak warnings. This is visible when Copilot initializes for an agent request in a profile where code quoting is disabled, including signed-out test profiles.

Create the channel only when code quoting is enabled or a citation is actually logged, and cover the lazy lifecycle with a regression test.
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

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

Ulugbek Abdullaev (@ulugbekna)

Matched files:

  • extensions/copilot/src/extension/completions-core/vscode-node/extension/src/codeReferencing/outputChannel.ts
  • extensions/copilot/src/extension/completions-core/vscode-node/extension/src/codeReferencing/test/codeReferencing.test.ts

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit 38312da into microsoft:main Oct 27, 2026
51 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.145.0 milestone Oct 27, 2026
@RReverser
Ingvar Stepanyan (RReverser) deleted the fix/copilot-code-reference-output-channel-race branch October 28, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants