@stinkycomputing/sesame-api-client 1.4.1-beta.2 → 1.4.1-beta.3
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.
- package/dist/index.browser.mjs +24 -1
- package/dist/index.browser.mjs.map +2 -2
- package/dist/index.cjs +24 -1
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +24 -1
- package/dist/index.mjs.map +2 -2
- package/dist/rpc-client.d.ts +7 -0
- package/dist/rpc-client.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -22283,10 +22283,33 @@ var RPCClient = class extends import_events.EventEmitter {
|
|
|
22283
22283
|
this.connection.on("rpc", (data) => this.messageHandler(data));
|
|
22284
22284
|
this.connection.on("error", this.errorHandler);
|
|
22285
22285
|
this.options = options;
|
|
22286
|
-
this.service = service.create(this.rpcImpl);
|
|
22286
|
+
this.service = this.wrapServicePromises(service.create(this.rpcImpl));
|
|
22287
22287
|
this.eventTypes = options.eventTypes || {};
|
|
22288
22288
|
this.sendTimeout = options.sendTimeout || 5 * 1e3;
|
|
22289
22289
|
}
|
|
22290
|
+
/**
|
|
22291
|
+
* Wraps service method calls to attach a rejection handler on all returned
|
|
22292
|
+
* promises. This prevents unhandled promise rejections (e.g. from timeouts
|
|
22293
|
+
* while disconnected) from crashing the host process. Callers can still
|
|
22294
|
+
* catch errors normally via await / .catch().
|
|
22295
|
+
*/
|
|
22296
|
+
wrapServicePromises(service) {
|
|
22297
|
+
const self = this;
|
|
22298
|
+
return new Proxy(service, {
|
|
22299
|
+
get(target, prop) {
|
|
22300
|
+
const value = target[prop];
|
|
22301
|
+
if (typeof value !== "function") return value;
|
|
22302
|
+
return function(...args) {
|
|
22303
|
+
const result = value.apply(target, args);
|
|
22304
|
+
if (result != null && typeof result.catch === "function") {
|
|
22305
|
+
result.catch(() => {
|
|
22306
|
+
});
|
|
22307
|
+
}
|
|
22308
|
+
return result;
|
|
22309
|
+
};
|
|
22310
|
+
}
|
|
22311
|
+
});
|
|
22312
|
+
}
|
|
22290
22313
|
async flushMessageBuffer() {
|
|
22291
22314
|
const messages = [];
|
|
22292
22315
|
for (const seq in this.messageBuffer) {
|