starpc 0.22.1 → 0.22.2
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.
|
@@ -9,6 +9,7 @@ export declare class CommonRPC {
|
|
|
9
9
|
private readonly _rpcDataSource;
|
|
10
10
|
protected service?: string;
|
|
11
11
|
protected method?: string;
|
|
12
|
+
private closed?;
|
|
12
13
|
constructor();
|
|
13
14
|
writeCallData(data?: Uint8Array, complete?: boolean, error?: string): Promise<void>;
|
|
14
15
|
writeCallCancel(): Promise<void>;
|
package/dist/srpc/common-rpc.js
CHANGED
|
@@ -116,6 +116,10 @@ export class CommonRPC {
|
|
|
116
116
|
}
|
|
117
117
|
// close closes the call, optionally with an error.
|
|
118
118
|
async close(err) {
|
|
119
|
+
if (this.closed) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
this.closed = true;
|
|
119
123
|
try {
|
|
120
124
|
await this.writeCallCancel();
|
|
121
125
|
}
|
|
@@ -141,15 +145,11 @@ export class CommonRPC {
|
|
|
141
145
|
await this.handlePacket(msg);
|
|
142
146
|
}
|
|
143
147
|
}
|
|
148
|
+
this._rpcDataSource.end();
|
|
144
149
|
}
|
|
145
150
|
catch (err) {
|
|
146
|
-
|
|
147
|
-
if (anyErr?.code !== 'ERR_STREAM_RESET' &&
|
|
148
|
-
anyErr?.code !== 'ERR_STREAM_ABORT') {
|
|
149
|
-
this.close(err);
|
|
150
|
-
}
|
|
151
|
+
this.close(err);
|
|
151
152
|
}
|
|
152
|
-
this._rpcDataSource.end();
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
155
|
}
|
package/package.json
CHANGED
package/srpc/common-rpc.ts
CHANGED
|
@@ -28,6 +28,9 @@ export class CommonRPC {
|
|
|
28
28
|
// method is the rpc method
|
|
29
29
|
protected method?: string
|
|
30
30
|
|
|
31
|
+
// closed indicates this rpc has been closed already.
|
|
32
|
+
private closed?: boolean
|
|
33
|
+
|
|
31
34
|
constructor() {
|
|
32
35
|
this.sink = this._createSink()
|
|
33
36
|
this.source = this._source
|
|
@@ -150,6 +153,10 @@ export class CommonRPC {
|
|
|
150
153
|
|
|
151
154
|
// close closes the call, optionally with an error.
|
|
152
155
|
public async close(err?: Error) {
|
|
156
|
+
if (this.closed) {
|
|
157
|
+
return
|
|
158
|
+
}
|
|
159
|
+
this.closed = true
|
|
153
160
|
try {
|
|
154
161
|
await this.writeCallCancel()
|
|
155
162
|
} finally {
|
|
@@ -174,16 +181,10 @@ export class CommonRPC {
|
|
|
174
181
|
await this.handlePacket(msg)
|
|
175
182
|
}
|
|
176
183
|
}
|
|
184
|
+
this._rpcDataSource.end()
|
|
177
185
|
} catch (err) {
|
|
178
|
-
|
|
179
|
-
if (
|
|
180
|
-
anyErr?.code !== 'ERR_STREAM_RESET' &&
|
|
181
|
-
anyErr?.code !== 'ERR_STREAM_ABORT'
|
|
182
|
-
) {
|
|
183
|
-
this.close(err as Error)
|
|
184
|
-
}
|
|
186
|
+
this.close(err as Error)
|
|
185
187
|
}
|
|
186
|
-
this._rpcDataSource.end()
|
|
187
188
|
}
|
|
188
189
|
}
|
|
189
190
|
}
|