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

Commit

Permalink
first cut of fix for #12 "do not try to reconnect on real quit"
Browse files Browse the repository at this point in the history
  • Loading branch information
weinand committed Dec 1, 2015
1 parent 7cecc34 commit 5f56f2e
Showing 1 changed file with 19 additions and 26 deletions.
45 changes: 19 additions & 26 deletions src/node/nodeDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,30 +291,19 @@ export class NodeDebugSession extends DebugSession {
// special code for 'extensionHost' debugging
if (this._adapterID === 'extensionHost') {

let extensionHostData = (<any>args).extensionHostData;
if (extensionHostData) {
// re-attach to the received port
port = extensionHostData.reattachPort;
} else {
// we know that extensionHost is always launched with --nolazy
this._lazy = false;

// we always launch in 'debug-brk' mode, but we only show the break event if 'stopOnEntry' attribute is true.
const launchArgs = [ runtimeExecutable, `--debugBrkPluginHost=${port}` ].concat(runtimeArgs, programArgs);
// we know that extensionHost is always launched with --nolazy
this._lazy = false;

this._sendLaunchCommandToConsole(launchArgs);
// we always launch in 'debug-brk' mode, but we only show the break event if 'stopOnEntry' attribute is true.
const launchArgs = [ runtimeExecutable, `--debugBrkPluginHost=${port}` ].concat(runtimeArgs, programArgs);

const cmd = CP.spawn(runtimeExecutable, launchArgs.slice(1));
cmd.on('error', (err) => {
this._terminated(`failed to launch extensionHost (${err})`);
});
this._captureOutput(cmd);
}
this._sendLaunchCommandToConsole(launchArgs);

// try to attach
setTimeout(() => {
this._attach(response, port, 3000);
}, 2000);
const cmd = CP.spawn(runtimeExecutable, launchArgs.slice(1));
cmd.on('error', (err) => {
this._terminated(`failed to launch extensionHost (${err})`);
});
this._captureOutput(cmd);

// we are done!
return;
Expand Down Expand Up @@ -468,15 +457,19 @@ export class NodeDebugSession extends DebugSession {

protected attachRequest(response: DebugProtocol.AttachResponse, args: AttachRequestArguments): void {

this._initializeSourceMaps(args);

if (!args.port) {
this.sendErrorResponse(response, 2008, "property 'port' is missing");
return;
}
const port = args.port;
this._attachMode = true;
this._attach(response, port);

if (this._adapterID === 'extensionHost') {
// in EH mode 'attach' is called after 'launch', so we stay in launch mode and we do not initialize source maps again
} else {
this._initializeSourceMaps(args);
this._attachMode = true;
}

this._attach(response, args.port);
}

/*
Expand Down

0 comments on commit 5f56f2e

Please sign in to comment.