Skip to content

Commit 638347c

Browse files
authored
fix: race condition when opening attached windows (#2196)
Fixes microsoft/vscode#239769
1 parent 1d87317 commit 638347c

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ This changelog records changes to stable releases since 1.50.2. "TBA" changes he
44

55
## 1.100 (April 2025)
66

7-
- fix: explicitly specify completion ranges ([[vscode#243409](https://github.com/microsoft/vscode/issues/243409)])
7+
- fix: explicitly specify completion ranges ([vscode#243409](https://github.com/microsoft/vscode/issues/243409))
88
- fix: memory leak between debug sessions ([#2173](https://github.com/microsoft/vscode-js-debug/issues/2173))
99
- fix: support `npm.scriptRunner: node`
1010
- fix: support "attach to node process" without wmic.exe and on arm64 ([vscode#244139](https://github.com/microsoft/vscode/issues/244139))
1111
- fix: support webview2 debugging on arm64
12+
- fix: race condition when opening attached windows ([vscode#239769](https://github.com/microsoft/vscode/issues/239769))
1213
- chore: enable experimental networking by default on recent Node versions
1314

1415
## 1.97 (January 2025)

src/targets/browser/browserTargetManager.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,9 @@ export class BrowserTargetManager implements IDisposable {
260260
// Also for service workers: https://bugs.chromium.org/p/chromium/issues/detail?id=1281013
261261
if (!jsTypes.has(type) || type === BrowserTargetType.ServiceWorker) {
262262
target.runIfWaitingForDebugger();
263-
} else if (type === BrowserTargetType.Page && waitForDebuggerOnStart) {
263+
} else if (
264+
type === BrowserTargetType.Page && waitForDebuggerOnStart && !targetInfo.canAccessOpener
265+
) {
264266
cdp.Page.waitForDebugger({});
265267
}
266268

src/targets/browser/browserTargets.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export class BrowserTarget implements ITarget {
9292
}
9393

9494
_children: Map<Cdp.Target.TargetID, BrowserTarget> = new Map();
95+
willWaitForDebugger: Promise<unknown> = Promise.resolve();
9596

9697
public readonly sourcePathResolver = this._manager._sourcePathResolver;
9798

@@ -150,7 +151,9 @@ export class BrowserTarget implements ITarget {
150151

151152
async runIfWaitingForDebugger() {
152153
await Promise.all([
153-
this._cdp.Runtime.runIfWaitingForDebugger({}),
154+
// If it can access the opener, the debugger state is shared with the parent,
155+
// and calling `runIfWaitingForDebugger` can resume the parent.
156+
!this._targetInfo.canAccessOpener && this._cdp.Runtime.runIfWaitingForDebugger({}),
154157
this._cdp.Runtime.evaluate({ expression: signalReadyExpr() }),
155158
]);
156159
}

0 commit comments

Comments
 (0)