@vastblast/capnweb 0.7.0 → 0.7.1
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-workers.cjs +11 -10
- package/dist/index-workers.cjs.map +1 -1
- package/dist/index-workers.js +11 -10
- package/dist/index-workers.js.map +1 -1
- package/dist/index.cjs +11 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index-workers.cjs
CHANGED
|
@@ -2067,14 +2067,17 @@ var RpcSessionImpl = class {
|
|
|
2067
2067
|
this.options = options;
|
|
2068
2068
|
this.exports.push({ hook: mainHook, refcount: 1 });
|
|
2069
2069
|
this.imports.push(new ImportTableEntry(this, 0, false));
|
|
2070
|
+
this.cancelReadLoop = (error) => {
|
|
2071
|
+
this.activeReadAbort?.reject(error);
|
|
2072
|
+
};
|
|
2070
2073
|
this.readLoop().catch((err) => this.abort(err));
|
|
2071
2074
|
}
|
|
2072
2075
|
exports = [];
|
|
2073
2076
|
reverseExports = /* @__PURE__ */ new Map();
|
|
2074
2077
|
imports = [];
|
|
2075
2078
|
abortReason;
|
|
2076
|
-
cancelReadLoop
|
|
2077
|
-
|
|
2079
|
+
cancelReadLoop;
|
|
2080
|
+
activeReadAbort;
|
|
2078
2081
|
// We assign positive numbers to imports we initiate, and negative numbers to exports we
|
|
2079
2082
|
// initiate. So the next import ID is just `imports.length`, but the next export ID needs
|
|
2080
2083
|
// to be tracked explicitly.
|
|
@@ -2390,17 +2393,15 @@ var RpcSessionImpl = class {
|
|
|
2390
2393
|
}
|
|
2391
2394
|
async readLoop() {
|
|
2392
2395
|
while (!this.abortReason) {
|
|
2393
|
-
let
|
|
2394
|
-
|
|
2395
|
-
rejectFunc = reject;
|
|
2396
|
-
});
|
|
2397
|
-
this.cancelReadLoop = rejectFunc;
|
|
2396
|
+
let readAbort = Promise.withResolvers();
|
|
2397
|
+
this.activeReadAbort = readAbort;
|
|
2398
2398
|
let msgText;
|
|
2399
2399
|
try {
|
|
2400
|
-
msgText = await Promise.race([this.transport.receive(),
|
|
2400
|
+
msgText = await Promise.race([this.transport.receive(), readAbort.promise]);
|
|
2401
2401
|
} finally {
|
|
2402
|
-
this.
|
|
2403
|
-
|
|
2402
|
+
if (this.activeReadAbort === readAbort) {
|
|
2403
|
+
this.activeReadAbort = void 0;
|
|
2404
|
+
}
|
|
2404
2405
|
}
|
|
2405
2406
|
let msg = JSON.parse(msgText);
|
|
2406
2407
|
if (this.abortReason) break;
|