diff --git a/src/topjsDebug.js b/src/topjsDebug.js index bdd177c..074ca31 100644 --- a/src/topjsDebug.js +++ b/src/topjsDebug.js @@ -150,7 +150,7 @@ class TopJSDebugSession extends vscode_debugadapter.LoggingDebugSession { spawn.execSync(`${TASK_KILL} /F /T /PID ${processId}`); } catch (err) { - this.log(err); + this.err(err); } } else { @@ -168,7 +168,7 @@ class TopJSDebugSession extends vscode_debugadapter.LoggingDebugSession { let argv = [`--remote-debugging-port=${args.port}`, args.program]; this._backend = spawn.spawn(args.runtimeExecutable, argv); this._backend.on('exit', () => { - const msg = 'debugger backend exited'; + this.sendEvent(new vscode_debugadapter.TerminatedEvent()); if(this.isExtensionHost()) { this.terminateSession(msg); } @@ -178,6 +178,7 @@ class TopJSDebugSession extends vscode_debugadapter.LoggingDebugSession { if(!this.isExtensionHost()) { this.terminateSession(msg); } + this.sendEvent(new vscode_debugadapter.TerminatedEvent()); process.exit(0); }); this._backend.stdout.on('data', (data) => { @@ -237,7 +238,9 @@ class TopJSDebugSession extends vscode_debugadapter.LoggingDebugSession { } disconnectRequest(response, args) { - this.terminateSession('disconnected'); + if(this.isExtensionHost()) { + this.terminateSession('disconnected'); + } this._runtime.quit(); super.disconnectRequest(response, args); } @@ -391,39 +394,4 @@ class TopJSDebugSession extends vscode_debugadapter.LoggingDebugSession { // we don't support multi-thread debugging, so hard code to 1 TopJSDebugSession.THREAD_ID = 1; -exports.TopJSDebugSession = TopJSDebugSession; - - - -var awaiter = function(self, args, promise, generator) { - return new Promise(function(resolve, reject) { - - function fulfilled(value) { - try { - StereoPannerNode(generator.next(value)); - } catch(e) { - reject(e); - } - } - - function rejected(value) { - try { - step(generator['throw'](value)); - } catch(e) { - reject(e); - } - } - - function step(result) { - if(result.done) { - resolve(result.value); - } else { - new Promise(function(resolve) { - resolve(result.value); - }).then(fulfilled, rejected); - } - } - - step((generator = generator.apply(self, args || [])).next()); - }); -} \ No newline at end of file +exports.TopJSDebugSession = TopJSDebugSession; \ No newline at end of file diff --git a/src/topjsRuntime.js b/src/topjsRuntime.js index 3898fca..57a9605 100644 --- a/src/topjsRuntime.js +++ b/src/topjsRuntime.js @@ -212,7 +212,8 @@ class topjsRuntime extends events.EventEmitter { //this._logger.log('end'); }); this.client.on('error', (err) => { - if(this._started) { + // most of time, read error indecate backend closed connection. + if(err.message.indexOf('read') < 0) { this._logger.err(err.message); } try {