@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.browser.mjs
CHANGED
|
@@ -22621,10 +22621,33 @@ var RPCClient = class extends import_events.EventEmitter {
|
|
|
22621
22621
|
this.connection.on("rpc", (data) => this.messageHandler(data));
|
|
22622
22622
|
this.connection.on("error", this.errorHandler);
|
|
22623
22623
|
this.options = options;
|
|
22624
|
-
this.service = service.create(this.rpcImpl);
|
|
22624
|
+
this.service = this.wrapServicePromises(service.create(this.rpcImpl));
|
|
22625
22625
|
this.eventTypes = options.eventTypes || {};
|
|
22626
22626
|
this.sendTimeout = options.sendTimeout || 5 * 1e3;
|
|
22627
22627
|
}
|
|
22628
|
+
/**
|
|
22629
|
+
* Wraps service method calls to attach a rejection handler on all returned
|
|
22630
|
+
* promises. This prevents unhandled promise rejections (e.g. from timeouts
|
|
22631
|
+
* while disconnected) from crashing the host process. Callers can still
|
|
22632
|
+
* catch errors normally via await / .catch().
|
|
22633
|
+
*/
|
|
22634
|
+
wrapServicePromises(service) {
|
|
22635
|
+
const self = this;
|
|
22636
|
+
return new Proxy(service, {
|
|
22637
|
+
get(target, prop) {
|
|
22638
|
+
const value = target[prop];
|
|
22639
|
+
if (typeof value !== "function") return value;
|
|
22640
|
+
return function(...args) {
|
|
22641
|
+
const result = value.apply(target, args);
|
|
22642
|
+
if (result != null && typeof result.catch === "function") {
|
|
22643
|
+
result.catch(() => {
|
|
22644
|
+
});
|
|
22645
|
+
}
|
|
22646
|
+
return result;
|
|
22647
|
+
};
|
|
22648
|
+
}
|
|
22649
|
+
});
|
|
22650
|
+
}
|
|
22628
22651
|
async flushMessageBuffer() {
|
|
22629
22652
|
const messages = [];
|
|
22630
22653
|
for (const seq in this.messageBuffer) {
|