@ricsam/isolate-daemon 0.1.19 → 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;
|
|
@@ -730,6 +731,7 @@ async function handleCreateRuntime(message, connection, state) {
|
|
|
730
731
|
return { ok: false, error: { name: error.name, message: error.message } };
|
|
731
732
|
}
|
|
732
733
|
},
|
|
734
|
+
timeout: message.options.playwright?.timeout,
|
|
733
735
|
console: playwrightCallbacks.console,
|
|
734
736
|
onEvent: (event) => {
|
|
735
737
|
const conn = callbackContext.connection;
|
|
@@ -1451,16 +1453,36 @@ function handleCallbackStreamStart(message, connection) {
|
|
|
1451
1453
|
return Promise.resolve();
|
|
1452
1454
|
}
|
|
1453
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
|
+
};
|
|
1454
1463
|
connection.callbackStreamReceivers.set(message.streamId, receiver);
|
|
1455
1464
|
const pending = connection.pendingCallbacks.get(message.requestId);
|
|
1456
|
-
if (pending) {
|
|
1457
|
-
|
|
1458
|
-
|
|
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, {
|
|
1459
1472
|
status: message.metadata.status,
|
|
1460
1473
|
statusText: message.metadata.statusText,
|
|
1461
1474
|
headers: message.metadata.headers
|
|
1462
1475
|
});
|
|
1476
|
+
connection.pendingCallbacks.delete(message.requestId);
|
|
1463
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);
|
|
1464
1486
|
}
|
|
1465
1487
|
}
|
|
1466
1488
|
function handleCallbackStreamChunk(message, connection) {
|
|
@@ -1726,4 +1748,4 @@ export {
|
|
|
1726
1748
|
handleConnection
|
|
1727
1749
|
};
|
|
1728
1750
|
|
|
1729
|
-
//# debugId=
|
|
1751
|
+
//# debugId=D1C19AA670E1882A64756E2164756E21
|