@vastblast/capnweb 0.7.5 → 0.7.6
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 -19
- package/dist/index-workers.cjs.map +1 -1
- package/dist/index-workers.js +11 -19
- package/dist/index-workers.js.map +1 -1
- package/dist/index.cjs +11 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index-workers.js
CHANGED
|
@@ -2373,7 +2373,17 @@ var RpcSessionImpl = class {
|
|
|
2373
2373
|
}
|
|
2374
2374
|
async readLoop() {
|
|
2375
2375
|
while (!this.abortReason) {
|
|
2376
|
-
let
|
|
2376
|
+
let readCanceled = Promise.withResolvers();
|
|
2377
|
+
this.cancelReadLoop = readCanceled.reject;
|
|
2378
|
+
let msgText;
|
|
2379
|
+
try {
|
|
2380
|
+
msgText = await Promise.race([this.transport.receive(), readCanceled.promise]);
|
|
2381
|
+
} finally {
|
|
2382
|
+
if (this.cancelReadLoop === readCanceled.reject) {
|
|
2383
|
+
this.cancelReadLoop = void 0;
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
let msg = JSON.parse(msgText);
|
|
2377
2387
|
if (this.abortReason) break;
|
|
2378
2388
|
if (msg instanceof Array) {
|
|
2379
2389
|
switch (msg[0]) {
|
|
@@ -2459,24 +2469,6 @@ var RpcSessionImpl = class {
|
|
|
2459
2469
|
throw new Error(`bad RPC message: ${JSON.stringify(msg)}`);
|
|
2460
2470
|
}
|
|
2461
2471
|
}
|
|
2462
|
-
// Use a fresh cancellation promise for each read. Reusing one session-long promise here causes
|
|
2463
|
-
// Promise.race() to accumulate reactions until the session is shut down.
|
|
2464
|
-
receiveOrAbort() {
|
|
2465
|
-
let readCanceled = Promise.withResolvers();
|
|
2466
|
-
this.cancelReadLoop = readCanceled.reject;
|
|
2467
|
-
let receivePromise;
|
|
2468
|
-
try {
|
|
2469
|
-
receivePromise = this.transport.receive();
|
|
2470
|
-
} catch (err) {
|
|
2471
|
-
this.cancelReadLoop = void 0;
|
|
2472
|
-
return Promise.reject(err);
|
|
2473
|
-
}
|
|
2474
|
-
return Promise.race([receivePromise, readCanceled.promise]).finally(() => {
|
|
2475
|
-
if (this.cancelReadLoop === readCanceled.reject) {
|
|
2476
|
-
this.cancelReadLoop = void 0;
|
|
2477
|
-
}
|
|
2478
|
-
});
|
|
2479
|
-
}
|
|
2480
2472
|
async drain() {
|
|
2481
2473
|
if (this.abortReason) {
|
|
2482
2474
|
throw this.abortReason;
|