src/vs/workbench/contrib/debug/node/debugAdapter.ts/NetworkDebugAdapter/startSession
class NetworkDebugAdapter:	startSession(): Promise<void> {
		return new Promise<void>((resolve, reject) => {
			let connected = false;

			this.socket = this.createConnection(() => {
				this.connect(this.socket!, this.socket!);
				resolve();
				connected = true;
			});

			this.socket.on('close', () => {
				if (connected) {
					this._onError.fire(new Error('connection closed'));
				} else {
					reject(new Error('connection closed'));
				}
			});

			this.socket.on('error', error => {
				if (connected) {
					this._onError.fire(error);
				} else {
					reject(error);
				}
			});
		});
	}