Fix "target closed" error in BrowserViewDebugger by checking isDestroyed before detach

Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/8233ab57-121b-4677-9a2b-aee47e824ba6

Co-authored-by: bryanchen-d <41454397+bryanchen-d@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-01 01:01:41 +00:00
committed by GitHub
parent 97e0df7ef4
commit 747b79d915

View File

@@ -168,6 +168,13 @@ export class BrowserViewDebugger extends Disposable implements ICDPTarget {
}
this._electronDebugger.removeListener('message', this._messageHandler);
// If the WebContents is already destroyed, there is nothing to detach from.
// This happens when disposal is triggered by the 'destroyed' event on the WebContents.
if (this.view.webContents.isDestroyed()) {
return;
}
try {
this._electronDebugger.detach();
} catch (error) {