Skip to content

Commit 47f1b00

Browse files
Vincent Johyangah
authored andcommitted
src/debugAdapter: adds error handling for remote connections
json-rpc2 module doesn't catch all the errors in its callback. If a remote connection fails to be established, it won't call the callback for errors. So the connection will hang. There are no future plans to handle the error case through the callback: json-rpc2: pocesar/node-jsonrpc2#53. Node.js handles errors in a similar way: https://nodejs.org/api/net.html#net_socket_connect. Errors won't be exposed through the callback, only through the error listener. Fixes #215 Change-Id: I75cfb2a0cf6628a8c35ddccf8c96ec1ade0275f1 GitHub-Last-Rev: 44d9b59 GitHub-Pull-Request: #216 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/237559 Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
1 parent 893333d commit 47f1b00

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/debugAdapter/goDebug.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ export class Delve {
600600
}
601601
return resolve(conn);
602602
});
603+
client.on('error', reject);
603604
}, 200);
604605
}
605606

typings/json-rpc2.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ declare module "json-rpc2" {
66
export class Client {
77
static $create(port: number, addr: string): Client;
88
connectSocket(callback: (err: Error, conn: RPCConnection) => void): void;
9+
on(handler: 'error', callback: (err: Error) => void): void;
910
}
1011
}

0 commit comments

Comments
 (0)