Skip to content

Guard ChatTipService against disposed scoped context key service#314757

Merged
meganrogge merged 2 commits into
mainfrom
copilot/fix-unhandled-error-context-key-service
May 6, 2026
Merged

Guard ChatTipService against disposed scoped context key service#314757
meganrogge merged 2 commits into
mainfrom
copilot/fix-unhandled-error-context-key-service

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 6, 2026

Unhandled error AbstractContextKeyService has been disposed from ChatTipService._hideShownTipIfNowIneligible -> _isEligible -> contextMatchesRules.

ChatTipService is a singleton that stashes the scoped IContextKeyService of whichever chat widget last requested a welcome tip. When that widget is torn down without resetSession() being called, the scoped service is disposed but the singleton retains the stale reference. The next IChatService.onDidSubmitRequest (a global event fired by any chat widget) then calls contextMatchesRules on the disposed service and throws.

Changes

  • chatTipService.ts — Wrap the eligibility check in _hideShownTipIfNowIneligible with try/catch; on throw, drop the stale _contextKeyService and bail (nothing to hide for a torn-down widget).
  • chatTipService.test.ts — Regression test: simulate a disposed scoped service by overriding contextMatchesRules to throw the matching error, then assert onDidSubmitRequest does not throw.
let eligible: boolean;
try {
    eligible = this._isEligible(this._shownTip, this._contextKeyService);
} catch (err) {
    // Stored scoped context key service was disposed (owning widget gone).
    this._contextKeyService = undefined;
    return;
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • redirector.gvt1.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --enable-crash-reporter=9e235240-25a7-4aa2-841e-a1b475510a49,no_channel --user-data-dir=/tmp/vscode-tests-1778081838979 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,2986972629153322651,12185066939970648515,262144 --enable-features=PdfUseShowSaveFilePicker --disable-features=LocalNetworkAccessChecks,ScreenAIOCREnabled,SpareRendererForSitePerProcess,TraceSiteInstanceGetProcessCreation --variations-seed-version --trace-process-track-uuid=3190708989122997041 (dns block)
    • Triggering command: ./.build/electron/code-oss ./.build/electron/code-oss --no-sandbox test/unit/electron/index.js --grep disposed --runGlob **/chat/test/**/chatTipService.test.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI self-assigned this May 6, 2026
Copilot AI review requested due to automatic review settings May 6, 2026 15:28
Copilot AI review requested due to automatic review settings May 6, 2026 15:28
Copilot AI linked an issue May 6, 2026 that may be closed by this pull request
…wnTipIfNowIneligible

Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/6a02e479-714c-4b80-b0f1-dcb69f4f36c4

Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 6, 2026 15:38
Copilot AI changed the title [WIP] Fix unhandled error for AbstractContextKeyService disposal Guard ChatTipService against disposed scoped context key service May 6, 2026
Copilot AI requested a review from meganrogge May 6, 2026 15:39
@meganrogge meganrogge marked this pull request as ready for review May 6, 2026 15:39
Copilot AI review requested due to automatic review settings May 6, 2026 15:39
@meganrogge meganrogge enabled auto-merge (squash) May 6, 2026 15:39
@meganrogge meganrogge merged commit 7de7ea8 into main May 6, 2026
30 checks passed
@meganrogge meganrogge deleted the copilot/fix-unhandled-error-context-key-service branch May 6, 2026 17:37
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.

[Error] unhandlederror-AbstractContextKeyService has been disposed

3 participants