@ai-ecoverse/slicc-kernel 1.7.0 → 1.7.2

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/node.js CHANGED
@@ -1453,6 +1453,8 @@ var SAB_I_STATUS = 2;
1453
1453
  var SAB_I_TOTAL = 3;
1454
1454
  var SAB_I_CHUNK = 4;
1455
1455
  var SAB_I_OFFSET = 5;
1456
+ var SAB_I_REQ = 6;
1457
+ var SAB_I_PUB = 7;
1456
1458
  var SAB_I_SIGNALS = 8;
1457
1459
  var SAB_I_TIMERS = 9;
1458
1460
  var SAB_STATE_READY = 2;
@@ -1507,6 +1509,10 @@ function attachSyncSabResponder(port, sab, token, opts) {
1507
1509
  pending.delete(id);
1508
1510
  }
1509
1511
  function publish(id, entry, offset) {
1512
+ if (Atomics.load(header2, SAB_I_REQ) !== id) {
1513
+ drop(id);
1514
+ return;
1515
+ }
1510
1516
  const chunk2 = Math.min(window.byteLength, entry.payload.byteLength - offset);
1511
1517
  if (chunk2 > 0) window.set(entry.payload.subarray(offset, offset + chunk2));
1512
1518
  Atomics.store(header2, SAB_I_STATUS, entry.status);
@@ -1515,7 +1521,8 @@ function attachSyncSabResponder(port, sab, token, opts) {
1515
1521
  Atomics.store(header2, SAB_I_OFFSET, offset);
1516
1522
  Atomics.store(header2, SAB_I_SEQ, id);
1517
1523
  Atomics.store(header2, SAB_I_STATE, SAB_STATE_READY);
1518
- Atomics.notify(header2, SAB_I_STATE);
1524
+ Atomics.add(header2, SAB_I_PUB, 1);
1525
+ Atomics.notify(header2, SAB_I_PUB);
1519
1526
  if (offset + chunk2 >= entry.payload.byteLength) drop(id);
1520
1527
  }
1521
1528
  function settle(id, result) {
@@ -3124,7 +3131,8 @@ var HttpHandles = class {
3124
3131
  else entry.left = next.value;
3125
3132
  } catch (e) {
3126
3133
  entry.done = true;
3127
- return { ok: false, errno: "EIO", message: message(e) };
3134
+ const timedOut = e?.code === "ETIMEDOUT";
3135
+ return { ok: false, errno: timedOut ? "ETIMEDOUT" : "EIO", message: message(e) };
3128
3136
  }
3129
3137
  }
3130
3138
  const bytes = entry.left.subarray(0, Math.max(0, max));
@@ -5760,6 +5768,26 @@ function signalNumber(name2) {
5760
5768
  return SIG[key];
5761
5769
  }
5762
5770
 
5771
+ // src/body-idle.ts
5772
+ var BODY_IDLE_MS = 5 * 60 * 1e3;
5773
+ function idleFailure(ms) {
5774
+ return Object.assign(new Error(`the response body sent no data for ${ms} ms`), {
5775
+ code: "ETIMEDOUT"
5776
+ });
5777
+ }
5778
+ async function readWithin(reader, ms) {
5779
+ if (!(ms > 0 && ms < Number.POSITIVE_INFINITY)) return reader.read();
5780
+ let timer;
5781
+ const idle = new Promise((_, reject) => {
5782
+ timer = setTimeout(() => reject(idleFailure(ms)), ms);
5783
+ });
5784
+ try {
5785
+ return await Promise.race([reader.read(), idle]);
5786
+ } finally {
5787
+ clearTimeout(timer);
5788
+ }
5789
+ }
5790
+
5763
5791
  // src/transport.ts
5764
5792
  var MAX_REQUEST_BODY = 64 * 1024 * 1024;
5765
5793
  function joinHeaders(headers) {
@@ -5772,11 +5800,11 @@ function joinHeaders(headers) {
5772
5800
  }
5773
5801
  return out;
5774
5802
  }
5775
- async function* chunks(body) {
5803
+ async function* chunks(body, idleMs) {
5776
5804
  if (!body) return;
5777
5805
  const reader = body.getReader();
5778
5806
  try {
5779
- for (let next = await reader.read(); !next.done; next = await reader.read()) {
5807
+ for (let next = await readWithin(reader, idleMs); !next.done; next = await readWithin(reader, idleMs)) {
5780
5808
  if (next.value.byteLength > 0) yield next.value;
5781
5809
  }
5782
5810
  } finally {
@@ -5817,7 +5845,7 @@ function fetchTransport(options = {}) {
5817
5845
  response.headers.forEach((value, name2) => {
5818
5846
  headers.push([name2, value]);
5819
5847
  });
5820
- const body = chunks(response.body);
5848
+ const body = chunks(response.body, options.bodyIdleMs ?? BODY_IDLE_MS);
5821
5849
  return {
5822
5850
  status: response.status,
5823
5851
  statusText: response.statusText,