@typerighter/rpc-client 0.25.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -46,6 +46,9 @@ export class JsonRpcClient {
46
46
  return;
47
47
  this.disposed = true;
48
48
  this.rejectAllPending('Connection disposed');
49
+ // Close the streams so the server detects the disconnect
50
+ this.reader.destroy();
51
+ this.writer.destroy();
49
52
  }
50
53
  // https://github.com/microsoft/vscode-languageserver-node/blob/5010cdf9822e1038a30ee7eb6ee5d7aaa79acc4a/jsonrpc/src/common/connection.ts#L565
51
54
  onClose(listener) {
package/dist/index.d.ts CHANGED
@@ -109,6 +109,8 @@ export declare class RpcClient {
109
109
  private constructor();
110
110
  static connectTcp(host: string, port: number): Promise<RpcClient>;
111
111
  static connectStdio(stdin: Readable, stdout: Writable): RpcClient;
112
+ /** Send exit notification and close the connection
113
+ * The detached server will detect the disconnect and save its cache */
112
114
  dispose(): void;
113
115
  onClose(callback: () => void): {
114
116
  dispose: () => void;
package/dist/index.js CHANGED
@@ -49,7 +49,10 @@ export class RpcClient {
49
49
  static connectStdio(stdin, stdout) {
50
50
  return new RpcClient(JsonRpcClient.connectStdio(stdin, stdout));
51
51
  }
52
+ /** Send exit notification and close the connection
53
+ * The detached server will detect the disconnect and save its cache */
52
54
  dispose() {
55
+ this.rpc.sendNotification('exit');
53
56
  this.rpc.dispose();
54
57
  }
55
58
  onClose(callback) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@typerighter/rpc-client",
4
- "version": "0.25.0",
4
+ "version": "0.26.0",
5
5
  "description": "JSON-RPC client for Typedown over TCP/stdio.",
6
6
  "repository": {
7
7
  "type": "git",
@@ -86,6 +86,9 @@ export class JsonRpcClient implements MessageConnection {
86
86
  this.disposed = true;
87
87
 
88
88
  this.rejectAllPending('Connection disposed');
89
+ // Close the streams so the server detects the disconnect
90
+ this.reader.destroy();
91
+ this.writer.destroy();
89
92
  }
90
93
 
91
94
  // https://github.com/microsoft/vscode-languageserver-node/blob/5010cdf9822e1038a30ee7eb6ee5d7aaa79acc4a/jsonrpc/src/common/connection.ts#L565
package/src/index.ts CHANGED
@@ -166,7 +166,10 @@ export class RpcClient {
166
166
  return new RpcClient(JsonRpcClient.connectStdio(stdin, stdout));
167
167
  }
168
168
 
169
+ /** Send exit notification and close the connection
170
+ * The detached server will detect the disconnect and save its cache */
169
171
  dispose (): void {
172
+ this.rpc.sendNotification('exit');
170
173
  this.rpc.dispose();
171
174
  }
172
175