@ai-ecoverse/slicc-kernel 1.136.2 → 1.136.3

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.
@@ -6699,7 +6699,7 @@ var KERNEL_VERSION, OS_RELEASE;
6699
6699
  var init_version = __esm({
6700
6700
  "src/version.ts"() {
6701
6701
  "use strict";
6702
- KERNEL_VERSION = true ? "1.136.2" : "0.0.0-dev";
6702
+ KERNEL_VERSION = true ? "1.136.3" : "0.0.0-dev";
6703
6703
  OS_RELEASE = "6.0.0-slicc";
6704
6704
  }
6705
6705
  });
package/dist/node.js CHANGED
@@ -7486,7 +7486,7 @@ function satisfies(version, range2) {
7486
7486
  }
7487
7487
 
7488
7488
  // src/version.ts
7489
- var KERNEL_VERSION = true ? "1.136.2" : "0.0.0-dev";
7489
+ var KERNEL_VERSION = true ? "1.136.3" : "0.0.0-dev";
7490
7490
  var OS_RELEASE = "6.0.0-slicc";
7491
7491
  function procVersion() {
7492
7492
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -22143,6 +22143,18 @@ var WasmProcess = class {
22143
22143
  throw err;
22144
22144
  }
22145
22145
  }
22146
+ async complain(line) {
22147
+ const stderr = this.fds.has(2) ? this.fds.get(2).file : void 0;
22148
+ if (!stderr?.write || stderr.sealed || stderr.clipboard) return false;
22149
+ const bytes = new TextEncoder().encode(`${line}
22150
+ `);
22151
+ const timeout = new Promise((r) => setTimeout(() => r(0), 1e3));
22152
+ const sent = await Promise.race([stderr.write(bytes, AbortSignal.timeout(1e3)), timeout]).then(
22153
+ (n) => n,
22154
+ () => 0
22155
+ );
22156
+ return sent > 0;
22157
+ }
22146
22158
  async clipboardComplaint(err) {
22147
22159
  const name2 = this.options.clipboardName;
22148
22160
  if (name2 === void 0 || !(err instanceof KernelError) || err.detail === void 0) return;
@@ -23618,6 +23630,29 @@ function outOfMemory(opts, data) {
23618
23630
  }
23619
23631
  return true;
23620
23632
  }
23633
+ function workerError(event) {
23634
+ return String(event.message ?? "worker error");
23635
+ }
23636
+ var CrashSlot = class {
23637
+ status;
23638
+ reported = false;
23639
+ report;
23640
+ constructor(report) {
23641
+ this.report = report;
23642
+ }
23643
+ take(status, message3, finish) {
23644
+ if (this.status) return;
23645
+ this.status = status;
23646
+ const done4 = () => {
23647
+ this.reported = true;
23648
+ finish(...status);
23649
+ };
23650
+ void this.report(message3).then(done4, done4);
23651
+ }
23652
+ };
23653
+ async function crashReport(process2, onError, message3) {
23654
+ if (!await process2.complain(message3)) onError?.(message3);
23655
+ }
23621
23656
  function spawnWasmProcess(opts) {
23622
23657
  const { promise: ready2, resolve: started } = readiness(opts.program.abi);
23623
23658
  const sab = new SharedArrayBuffer(SAB_HEADER_BYTES + SAB_DEFAULT_WINDOW_BYTES);
@@ -23668,9 +23703,11 @@ function spawnWasmProcess(opts) {
23668
23703
  const jsThreads = jsThreadsOf(opts, process2, token, dispatch2, clocks, header4);
23669
23704
  const { promise: exited, resolve: settle } = Promise.withResolvers();
23670
23705
  let done4 = false;
23706
+ const crash = new CrashSlot((message3) => crashReport(process2, opts.onError, message3));
23671
23707
  let endedBy;
23672
23708
  const finish = (code, sig) => {
23673
23709
  if (done4) return;
23710
+ if (crash.status && !crash.reported) return;
23674
23711
  done4 = true;
23675
23712
  started(true);
23676
23713
  clocks.freeze();
@@ -23699,8 +23736,9 @@ function spawnWasmProcess(opts) {
23699
23736
  } else if (data?.type === WASM_PROCESS_EXIT) {
23700
23737
  finish(...dying.status(data.code));
23701
23738
  } else if (data?.type === WASM_PROCESS_ERROR) {
23702
- if (!dying.ending) opts.onError?.(String(data.message));
23703
- finish(...dying.status(data.code));
23739
+ const status = dying.status(data.code);
23740
+ if (dying.ending) finish(...status);
23741
+ else crash.take(status, String(data.message), finish);
23704
23742
  } else if (data?.type === WASM_THREAD_SPAWN && data.thread) {
23705
23743
  spawnThread(data.thread);
23706
23744
  } else if (data?.type === JS_THREAD_SPAWN && jsThreads) {
@@ -23710,8 +23748,7 @@ function spawnWasmProcess(opts) {
23710
23748
  const onMessage = (event) => handle(event.data);
23711
23749
  const onError = (event) => {
23712
23750
  event.preventDefault();
23713
- opts.onError?.(String(event.message ?? "worker error"));
23714
- finish(CRASHED);
23751
+ crash.take([CRASHED], workerError(event), finish);
23715
23752
  };
23716
23753
  worker.addEventListener("message", onMessage);
23717
23754
  worker.addEventListener("error", onError);