Skip to content

Commit

Permalink
Merge pull request #394 from vladimir-kotikov/fix-races-on-attach
Browse files Browse the repository at this point in the history
Fix race conditions when reloading app on device
  • Loading branch information
MSLaguana authored Feb 13, 2017
2 parents b42a1c4 + 6c75098 commit 64c6648
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/debugger/nodeDebugWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,8 @@ export function makeSession(debugSessionClass: typeof ChromeDebuggerCorePackage.
public sendEvent(event: VSCodeDebugAdapterPackage.Event): void {
// Do not send "terminated" events signaling about session's restart to client as it would cause it
// to restart adapter's process, while we want to stay alive and don't want to interrupt connection
// to packager. Also in this case we need to reinstantiate the debug adapter, as the current
// implementation of ChromeDebugAdapter doesn't allow us to reattach to another debug target easily.
// As of now it's easier to throw previous instance out and create a new one.
// to packager.
if (event.event === "terminated" && event.body && event.body.restart === true) {
// Casting debugAdapter to any to make this compile, as TS doesn't allow instantiating abstract classes
this._debugAdapter = new (<any>debugSessionOpts.adapter)(debugSessionOpts, this);
return;
}

Expand Down Expand Up @@ -185,6 +181,10 @@ export function makeSession(debugSessionClass: typeof ChromeDebuggerCorePackage.
let attachArguments = Object.assign({}, request.arguments, { port, restart: true, request: "attach" });
let attachRequest = Object.assign({}, request, { command: "attach", arguments: attachArguments });

// Reinstantiate debug adapter, as the current implementation of ChromeDebugAdapter
// doesn't allow us to reattach to another debug target easily. As of now it's easier
// to throw previous instance out and create a new one.
this._debugAdapter = new (<any>debugSessionOpts.adapter)(debugSessionOpts, this);
super.dispatchRequest(attachRequest);
});

Expand Down

0 comments on commit 64c6648

Please sign in to comment.