@standardserver/peer 0.0.12 → 0.0.15
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.mjs +13 -13
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -99,16 +99,16 @@ function toOctetStream(queue, cleanup) {
|
|
|
99
99
|
controller.enqueue(binary instanceof Uint8Array ? binary : new Uint8Array(await binary.arrayBuffer()));
|
|
100
100
|
}
|
|
101
101
|
if (json.close) {
|
|
102
|
-
await cleanup({
|
|
102
|
+
await cleanup({ kind: "success" });
|
|
103
103
|
controller.close();
|
|
104
104
|
}
|
|
105
105
|
} catch (error) {
|
|
106
|
-
await cleanup({
|
|
106
|
+
await cleanup({ kind: "error", error });
|
|
107
107
|
controller.error(error);
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
|
-
async cancel() {
|
|
111
|
-
await cleanup({
|
|
110
|
+
async cancel(error) {
|
|
111
|
+
await cleanup({ kind: "cancelled", error });
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
114
|
}
|
|
@@ -202,7 +202,7 @@ function toStandardBody(message, cleanup) {
|
|
|
202
202
|
errorRef = { value: error };
|
|
203
203
|
throw error;
|
|
204
204
|
} finally {
|
|
205
|
-
await cleanup(errorRef ? {
|
|
205
|
+
await cleanup(errorRef ? { kind: "error", error: errorRef.value } : { kind: "success" });
|
|
206
206
|
}
|
|
207
207
|
};
|
|
208
208
|
return { resolveBody };
|
|
@@ -348,11 +348,11 @@ class ClientPeer {
|
|
|
348
348
|
const resolve = state.resolve;
|
|
349
349
|
state.resolve = void 0;
|
|
350
350
|
try {
|
|
351
|
-
const decoded = toStandardBody(message, async (
|
|
352
|
-
if (
|
|
353
|
-
await this.abortById(id, error);
|
|
351
|
+
const decoded = toStandardBody(message, async (cleanupState) => {
|
|
352
|
+
if (cleanupState.kind === "cancelled") {
|
|
353
|
+
await this.abortById(id, cleanupState.error);
|
|
354
354
|
} else if (state.eventStreamMessageQueue || state.octetStreamMessageQueue) {
|
|
355
|
-
await this.closeById(id, error);
|
|
355
|
+
await this.closeById(id, cleanupState.error);
|
|
356
356
|
}
|
|
357
357
|
});
|
|
358
358
|
state.eventStreamMessageQueue = decoded.eventStreamMessageQueue;
|
|
@@ -554,8 +554,8 @@ class HibernationEventIterator extends AsyncIteratorClass {
|
|
|
554
554
|
constructor(hibernationCallback) {
|
|
555
555
|
super(async () => {
|
|
556
556
|
throw new Error("Cannot use hibernating iterator directly");
|
|
557
|
-
}, async ({
|
|
558
|
-
if (
|
|
557
|
+
}, async ({ kind }) => {
|
|
558
|
+
if (kind === "cancelled") {
|
|
559
559
|
throw new Error("Cannot use hibernating iterator directly");
|
|
560
560
|
}
|
|
561
561
|
});
|
|
@@ -599,8 +599,8 @@ class ServerPeer {
|
|
|
599
599
|
this.requests.set(id, state);
|
|
600
600
|
const signal = controller.signal;
|
|
601
601
|
try {
|
|
602
|
-
const decoded = toStandardBody(message, async ({
|
|
603
|
-
if (
|
|
602
|
+
const decoded = toStandardBody(message, async ({ kind }) => {
|
|
603
|
+
if (kind === "cancelled" && (state.eventStreamMessageQueue || state.octetStreamMessageQueue)) {
|
|
604
604
|
state.eventStreamMessageQueue = void 0;
|
|
605
605
|
state.octetStreamMessageQueue = void 0;
|
|
606
606
|
await this.send({ id, kind: "stream/cancel" });
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@standardserver/peer",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.15",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://standardserver.dev",
|
|
7
7
|
"repository": {
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"dist"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@standardserver/core": "0.0.
|
|
25
|
-
"@standardserver/shared": "0.0.
|
|
24
|
+
"@standardserver/core": "0.0.15",
|
|
25
|
+
"@standardserver/shared": "0.0.15"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "unbuild",
|