Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Stop debugging on program end #112

Merged
merged 2 commits into from
Jun 19, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions src/nodeDebugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ export class NodeDebugAdapter extends ChromeDebugAdapter {
super.commonArgs(args);
}

protected hookConnectionEvents(): void {
super.hookConnectionEvents();

this.chrome.Runtime.onExecutionContextDestroyed(params => {
if (params.executionContextId === 1) {
this.terminateSession('Program ended');
}
});
}

protected async doAttach(port: number, targetUrl?: string, address?: string, timeout?: number): Promise<any> {
await super.doAttach(port, targetUrl, address, timeout);
this.beginWaitingForDebuggerPaused();
Expand Down
8 changes: 6 additions & 2 deletions test/adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ suite('Node Debug Adapter etc', () => {
});

suite('launch', () => {
// #11
test.skip('should run program to the end', () => {
test('should run program to the end', () => {
if (testSetup.compareSemver(process.version, 'v8.0.0') < 0) {
// Skip test if the node version doesn't emit the Runtime.executionContextDestroyed event
return Promise.resolve();
}

const PROGRAM = path.join(DATA_ROOT, 'program.js');

return Promise.all([
Expand Down