@ricsam/isolate-client 0.1.17 → 0.1.18
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/mjs/connection.mjs
CHANGED
|
@@ -629,6 +629,8 @@ async function createRuntime(state, options = {}, namespaceId) {
|
|
|
629
629
|
if (signal?.aborted) {
|
|
630
630
|
throw new DOMException("The operation was aborted", "AbortError");
|
|
631
631
|
}
|
|
632
|
+
const requestSignal = req.signal;
|
|
633
|
+
const requestSignalInitiallyAborted = requestSignal?.aborted ?? false;
|
|
632
634
|
const reqId = state.nextRequestId++;
|
|
633
635
|
const serialized = await serializeRequestWithStreaming(state, req);
|
|
634
636
|
const { bodyStream, ...serializableRequest } = serialized;
|
|
@@ -655,6 +657,23 @@ async function createRuntime(state, options = {}, namespaceId) {
|
|
|
655
657
|
};
|
|
656
658
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
657
659
|
}
|
|
660
|
+
let onRequestAbort;
|
|
661
|
+
if (requestSignal && !requestSignalInitiallyAborted) {
|
|
662
|
+
onRequestAbort = () => {
|
|
663
|
+
const abortMessage = {
|
|
664
|
+
type: MessageType.DISPATCH_REQUEST_ABORT,
|
|
665
|
+
isolateId,
|
|
666
|
+
targetRequestId: reqId
|
|
667
|
+
};
|
|
668
|
+
if (state.connected) {
|
|
669
|
+
sendMessage(state.socket, abortMessage);
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
requestSignal.addEventListener("abort", onRequestAbort, { once: true });
|
|
673
|
+
if (requestSignal.aborted) {
|
|
674
|
+
onRequestAbort();
|
|
675
|
+
}
|
|
676
|
+
}
|
|
658
677
|
try {
|
|
659
678
|
if (serialized.bodyStreamId !== undefined && bodyStream) {
|
|
660
679
|
const streamId = serialized.bodyStreamId;
|
|
@@ -670,6 +689,9 @@ async function createRuntime(state, options = {}, namespaceId) {
|
|
|
670
689
|
if (signal && onAbort) {
|
|
671
690
|
signal.removeEventListener("abort", onAbort);
|
|
672
691
|
}
|
|
692
|
+
if (requestSignal && onRequestAbort) {
|
|
693
|
+
requestSignal.removeEventListener("abort", onRequestAbort);
|
|
694
|
+
}
|
|
673
695
|
}
|
|
674
696
|
},
|
|
675
697
|
async getUpgradeRequest() {
|
|
@@ -1000,12 +1022,16 @@ function registerFetchCallback(state, callback) {
|
|
|
1000
1022
|
state.callbacksNeedingRequestId.add(callbackId);
|
|
1001
1023
|
state.callbacks.set(callbackId, async (serialized, requestId) => {
|
|
1002
1024
|
const data = serialized;
|
|
1025
|
+
const signalController = new AbortController;
|
|
1026
|
+
if (data.signalAborted) {
|
|
1027
|
+
signalController.abort();
|
|
1028
|
+
}
|
|
1003
1029
|
const init = {
|
|
1004
1030
|
method: data.method,
|
|
1005
1031
|
headers: data.headers,
|
|
1006
1032
|
rawBody: data.body ?? null,
|
|
1007
1033
|
body: data.body ?? null,
|
|
1008
|
-
signal:
|
|
1034
|
+
signal: signalController.signal
|
|
1009
1035
|
};
|
|
1010
1036
|
const response = await callback(data.url, init);
|
|
1011
1037
|
const contentLength = response.headers.get("content-length");
|
|
@@ -1376,7 +1402,8 @@ async function serializeRequestWithStreaming(state, request) {
|
|
|
1376
1402
|
method: request.method,
|
|
1377
1403
|
url: request.url,
|
|
1378
1404
|
headers,
|
|
1379
|
-
body
|
|
1405
|
+
body,
|
|
1406
|
+
signalAborted: request.signal?.aborted ?? false
|
|
1380
1407
|
};
|
|
1381
1408
|
if (bodyStreamId !== undefined) {
|
|
1382
1409
|
result.bodyStreamId = bodyStreamId;
|
|
@@ -1637,4 +1664,4 @@ export {
|
|
|
1637
1664
|
connect
|
|
1638
1665
|
};
|
|
1639
1666
|
|
|
1640
|
-
//# debugId=
|
|
1667
|
+
//# debugId=7EA890CF5E7314ED64756E2164756E21
|