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