@ricsam/isolate-daemon 0.1.20 → 0.1.21
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/cjs/package.json
CHANGED
package/dist/mjs/connection.mjs
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
createRuntime
|
|
20
20
|
} from "@ricsam/isolate-runtime";
|
|
21
21
|
var LINKER_CONFLICT_ERROR = "Module is currently being linked by another linker";
|
|
22
|
+
var NULL_BODY_STATUSES = new Set([101, 103, 204, 205, 304]);
|
|
22
23
|
function getErrorText(error) {
|
|
23
24
|
if (error instanceof Error) {
|
|
24
25
|
const cause = error.cause;
|
|
@@ -1452,16 +1453,36 @@ function handleCallbackStreamStart(message, connection) {
|
|
|
1452
1453
|
return Promise.resolve();
|
|
1453
1454
|
}
|
|
1454
1455
|
});
|
|
1456
|
+
const cancelStream = () => {
|
|
1457
|
+
connection.callbackStreamReceivers.delete(message.streamId);
|
|
1458
|
+
sendMessage(connection.socket, {
|
|
1459
|
+
type: MessageType.CALLBACK_STREAM_CANCEL,
|
|
1460
|
+
streamId: message.streamId
|
|
1461
|
+
});
|
|
1462
|
+
};
|
|
1455
1463
|
connection.callbackStreamReceivers.set(message.streamId, receiver);
|
|
1456
1464
|
const pending = connection.pendingCallbacks.get(message.requestId);
|
|
1457
|
-
if (pending) {
|
|
1458
|
-
|
|
1459
|
-
|
|
1465
|
+
if (!pending) {
|
|
1466
|
+
cancelStream();
|
|
1467
|
+
return;
|
|
1468
|
+
}
|
|
1469
|
+
try {
|
|
1470
|
+
const body = NULL_BODY_STATUSES.has(message.metadata.status) ? null : readableStream;
|
|
1471
|
+
const response = new Response(body, {
|
|
1460
1472
|
status: message.metadata.status,
|
|
1461
1473
|
statusText: message.metadata.statusText,
|
|
1462
1474
|
headers: message.metadata.headers
|
|
1463
1475
|
});
|
|
1476
|
+
connection.pendingCallbacks.delete(message.requestId);
|
|
1464
1477
|
pending.resolve({ __streamingResponse: true, response });
|
|
1478
|
+
if (body === null) {
|
|
1479
|
+
cancelStream();
|
|
1480
|
+
}
|
|
1481
|
+
} catch (err) {
|
|
1482
|
+
connection.pendingCallbacks.delete(message.requestId);
|
|
1483
|
+
cancelStream();
|
|
1484
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
1485
|
+
pending.reject(error);
|
|
1465
1486
|
}
|
|
1466
1487
|
}
|
|
1467
1488
|
function handleCallbackStreamChunk(message, connection) {
|
|
@@ -1727,4 +1748,4 @@ export {
|
|
|
1727
1748
|
handleConnection
|
|
1728
1749
|
};
|
|
1729
1750
|
|
|
1730
|
-
//# debugId=
|
|
1751
|
+
//# debugId=D1C19AA670E1882A64756E2164756E21
|