Skip to content

Listener leak in chatEditingEditorOverlay causes Extension Host crash when Copilot Chat is open alongside Flutter/Dart project #304580

@Tarek-higazi

Description

@Tarek-higazi
  • Copilot Chat Extension Version: 0.40.1
  • VS Code Version: 1.112.0
  • OS Version: macOS
  • Feature: Edit mode
  • Selected model: Claude Sonnet 4.6
  • Logs:
    "ERR [1c9] potential listener LEAK detected, having 323 listeners already. MOST frequent listener (89):: Error
    at a.create (event.ts:1061:15)
    at Yoi._event [as onDidChange] (event.ts:1246:34)
    at new tr (toolbar.ts:382:1)
    at a._createInstance (instantiationService.ts:162:18)
    at a.createInstance (instantiationService.ts:128:18)
    at new AG (chatEditingCodeEditorIntegration.ts:760:1)
    at a._createInstance (instantiationService.ts:162:18)
    at a.createInstance (instantiationService.ts:128:18)
    at chatEditingCodeEditorIntegration.ts:450:1
    at a.invokeFunction (instantiationService.ts:109:11)
    at Ur.invokeWithinContext (codeEditorWidget.ts:442:1)
    at chatEditingCodeEditorIntegration.ts:448:1
    at MOo (viewZones.ts:418:10)
    at viewZones.ts:223:4
    at a.changeWhitespace (linesLayout.ts:204:4)
    at ySt.changeWhitespace (viewLayout.ts:378:40)
    at MSt.changeWhitespace (viewModelImpl.ts:1254:38)
    at Qvt.changeViewZones (viewZones.ts:202:27)
    at $ye.change (view.ts:720:19)
    at Ur.changeViewZones (codeEditorWidget.ts:1658:1)
    at PG._updateDiffRendering (chatEditingCodeEditorIntegration.ts:352:1)
    at KW._runFn (chatEditingCodeEditorIntegration.ts:200:1)
    at KW._run (autorunImpl.ts:110:11)
    at new KW (autorunImpl.ts:58:8)
    at Se (autorun.ts:18:9)
    at new PG (chatEditingCodeEditorIntegration.ts:184:1)
    at a._createInstance (instantiationService.ts:162:18)
    at a.createInstance (instantiationService.ts:128:18)
    at Xie._createEditorIntegration (chatEditingModifiedDocumentEntry.ts:307:1)
    at Xie.getEditorIntegration (chatEditingModifiedFileEntry.ts:313:1)
    at Qv._computeFn (chatEditingEditorOverlay.ts:365:1)
    at Qv._recompute (derivedImpl.ts:201:24)
    at Qv.get (derivedImpl.ts:159:11)
    at KW.readObservable (autorunImpl.ts:225:28)
    at Qv.read (baseObservable.ts:54:18)
    at KW._runFn (chatEditingEditorOverlay.ts:169:1)
    at KW._run (autorunImpl.ts:110:11)
    at new KW (autorunImpl.ts:58:8)
    at Se (autorun.ts:18:9)
    at ftt.show (chatEditingEditorOverlay.ts:166:1)
    at KW._runFn (chatEditingEditorOverlay.ts:373:1)
    at KW._run (autorunImpl.ts:110:11)
    at KW.endUpdate (autorunImpl.ts:167:12)
    at Qv.endUpdate (derivedImpl.ts:281:7)
    at Qv.endUpdate (derivedImpl.ts:281:7)
    at VN.finish (transaction.ts:102:13)
    at Qi (transaction.ts:21:6)
    at AYt.handleEvent (observableSignalFromEvent.ts:41:3)
    at tSe.value (event.ts:194:85)
    at E._deliver (event.ts:1338:13)
    at E._deliverQueue (event.ts:1349:9)
    at E.fire (event.ts:1373:9)
    at editorGroupView.ts:1269:1
    at async Kw.openAnything (anythingQuickAccess.ts:1130:1)"

Steps to Reproduce:

  1. Open a Flutter/Dart project in VS Code with Copilot Chat enabled
  2. Open Copilot Chat and send any message
  3. Switch between editor tabs a few times
  4. Open Help > Toggle Developer Tools > Console and observe
    "potential listener LEAK detected" errors growing to 300-400+ listeners
  5. Eventually the extension host crashes with "Debug adapter process
    has terminated unexpectedly (Extension host shut down)",
    killing the Flutter debug session

Root cause visible in stack trace:
_autoAttachInstructions → findAgentSkills → computeSkillDiscoveryInfo
→ chatEditingEditorOverlay.show() → _createEditorIntegration
→ _updateDiffRendering → new toolbar created but never disposed,
leaking ~89-131 listeners per tab switch.

Regression noticed in 1.111.0, still present in 1.112.0.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions