Skip to content

Commit c6ef922

Browse files
committed
don't exit() in 'inline' mode
1 parent 6748fc6 commit c6ef922

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

adapter/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

adapter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vscode-debugadapter",
33
"description": "Debug adapter implementation for node",
4-
"version": "1.38.0-pre.3",
4+
"version": "1.38.0-pre.4",
55
"author": "Microsoft Corporation",
66
"license": "MIT",
77
"repository": {

adapter/src/debugSession.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ export class DebugSession extends ProtocolServer {
369369
}
370370

371371
public shutdown(): void {
372-
if (this._isServer) {
372+
if (this._isServer || this._isRunningInline()) {
373373
// shutdown ignored in server mode
374374
} else {
375375
// wait a bit before shutting down

adapter/src/protocol.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ class Emitter<T> {
5858
}
5959
}
6060

61+
hasListener() : boolean {
62+
return !!this._listener;
63+
}
64+
6165
dispose() {
6266
this._listener = undefined;
6367
this._this = undefined;
@@ -78,7 +82,7 @@ export class ProtocolServer extends ee.EventEmitter implements VSCodeDebugAdapte
7882

7983
private static TWO_CRLF = '\r\n\r\n';
8084

81-
private sendMessage = new Emitter<DebugProtocolMessage>();
85+
private _sendMessage = new Emitter<DebugProtocolMessage>();
8286

8387
private _rawData: Buffer;
8488
private _contentLength: number;
@@ -95,7 +99,7 @@ export class ProtocolServer extends ee.EventEmitter implements VSCodeDebugAdapte
9599
public dispose(): any {
96100
}
97101

98-
public onDidSendMessage: Event0<DebugProtocolMessage> = this.sendMessage.event;
102+
public onDidSendMessage: Event0<DebugProtocolMessage> = this._sendMessage.event;
99103

100104
public handleMessage(msg: DebugProtocol.ProtocolMessage): void {
101105
if (msg.type === 'request') {
@@ -110,6 +114,10 @@ export class ProtocolServer extends ee.EventEmitter implements VSCodeDebugAdapte
110114
}
111115
}
112116

117+
protected _isRunningInline() {
118+
return this._sendMessage && this._sendMessage.hasListener();
119+
}
120+
113121
//--------------------------------------------------------------------------
114122

115123
public start(inStream: NodeJS.ReadableStream, outStream: NodeJS.WritableStream): void {
@@ -201,7 +209,7 @@ export class ProtocolServer extends ee.EventEmitter implements VSCodeDebugAdapte
201209
const json = JSON.stringify(message);
202210
this._writableStream.write(`Content-Length: ${Buffer.byteLength(json, 'utf8')}\r\n\r\n${json}`, 'utf8');
203211
}
204-
this.sendMessage.fire(message);
212+
this._sendMessage.fire(message);
205213
}
206214

207215
private _handleData(data: Buffer): void {

0 commit comments

Comments
 (0)