Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: stop global setup when debugger is terminated attempt #2 #537

Merged
merged 6 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,19 +534,7 @@ export class Extension implements RunHooks {
};

if (mode === 'debug') {
const debugEnd = new this._vscode.CancellationTokenSource();
testRun.token.onCancellationRequested(() => debugEnd.cancel());

let mainDebugRun: vscodeTypes.DebugSession | undefined;
this._vscode.debug.onDidStartDebugSession(session => { mainDebugRun ??= session; });
this._vscode.debug.onDidTerminateDebugSession(session => {
// child processes have their own debug sessions,
// but we only want to stop debugging if the user cancels the main session
if (session.id === mainDebugRun?.id)
debugEnd.cancel();
});

await model.debugTests(items, testListener, debugEnd.token);
await model.debugTests(items, testListener, testRun.token);
} else {
// Force trace viewer update to surface check version errors.
await this._models.selectedModel()?.updateTraceViewer(mode === 'run')?.willRunTests();
Expand Down
17 changes: 17 additions & 0 deletions src/playwrightTestServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,23 @@ export class PlaywrightTestServer {
let debugTestServer: TestServerConnection | undefined;
const disposables: vscodeTypes.Disposable[] = [];
try {
const debugEnd = new this._vscode.CancellationTokenSource();
token.onCancellationRequested(() => debugEnd.cancel());

let mainDebugRun: vscodeTypes.DebugSession | undefined;
this._vscode.debug.onDidStartDebugSession(session => {
if (session.name === 'Playwright Test')
mxschmitt marked this conversation as resolved.
Show resolved Hide resolved
mainDebugRun ??= session;
});
this._vscode.debug.onDidTerminateDebugSession(session => {
// child processes have their own debug sessions,
// but we only want to stop debugging if the user cancels the main session
if (session.id === mainDebugRun?.id)
debugEnd.cancel();
});

token = debugEnd.token;

await this._vscode.debug.startDebugging(undefined, {
type: 'pwa-node',
name: debugSessionName,
Expand Down
Loading