jspi: fix the dead-tools ownership bug, emscripten-6 fallout, and green the full suite on Playwright 1.62

Live-app fix (Place Footprints / routing dead in Chrome): submodule
bumps carry the coroutine ownership fix (kicad 012d95ecb4) and the
handler-exception survival fix (wxwidgets 1b5f0e31f4).

Emscripten-6 fallout:
- occ/ngspice worker wrappers: mainScriptUrlOrBlob was removed
  upstream; pthread children re-run the wrapper blob, so an em-pthread
  realm now importScripts the glue and gets out of the way (before:
  recursive service boots, pool never fills, silent 180s boot hangs —
  every occ spec and ngspice bg_run).
- Makefile.wasm: -sASYNCIFY frankenlinks on the no-wx coroutine repro
  targets ported to -sJSPI (the JSPI-only libcontext crashed at first
  yield under them); mainloop/gl repro pages drive their tick through a
  promising export (emscripten_set_main_loop callbacks cannot suspend);
  retired inject-dyncall-shims lines removed (targets were unbuildable
  since Phase 8); $stringToNewUTF8 force-included (the EM_ASM value
  bridge aborted the runtime on the first decoded exception).
- fiber-park levers: neither embind shape can drive suspending levers
  (plain throws on strict-JSPI Firefox; emscripten::async() re-executes
  its invoker on settle) — kept sync for manual Chromium probing, spec
  coverage moved to the jspi-coroutine harness (18 cases).

Suite work:
- Playwright 1.61.1 -> 1.62.1 (Firefox 153: JSPI on by default).
- fiber-resume-park.spec retired -> coroutine-lifecycle.spec: census
  gate over boot / board load / chooser open / cancel (deterministically
  red on the pre-fix build).
- Blind asyncify-era pins re-keyed: quasimodal-strand + wait-beacons
  beacon regexes, footprint-chooser-close liveness -> wx parking-timer
  heartbeat (scheduler counters idle flat on Firefox).
- occ/ngspice test providers: 60s boot timeout + worker error
  surfacing (a worker death used to be a silent 180s timeout).
- Harness pages: stale 9.99 config dir -> 10.0 (library_manager wxCHECK
  noise, chooser had no libraries).
- gal-webgl harness: missing artifacts rebuilt (boost/glm extracted to
  the host sysroot), PgmOrNull stub added for the rebased GAL.
- jspi-scheduler: clean-shutdown console line restored (app-quit
  contract), quarantine never yanks SP from a live window.

Gates: test:e2e 699 passed / 0 failed (wx-chromium, kicad-firefox,
kicad-chromium, jspi-firefox, coroutine-firefox); web ff/cr/mobile 71
passed; lint:ci-coverage 166, lint:determinism 163, screenshots
manifest 492 current, corpus 7/7, tools:contract green. Offline
screenshot baselines show expected mass drift from the engine bump —
re-baseline (screenshots:noise -> promote) is a follow-up.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016X9eh1s5sTx1o9Em9KBuwR
This commit is contained in:
Viktor Vaczi 2026-08-13 17:41:28 +02:00
commit db819850ee
31 changed files with 577 additions and 359 deletions

View file

@ -0,0 +1,193 @@
import type { Page } from "@playwright/test";
import { test, expect } from "./fixtures";
import { loadBoard } from "./utils/threed-viewer";
import { waitForPcbnew } from "./utils/pcbnew-ready";
import { clickMenuBarItem, clickMenuItemByText } from "../e2e/utils/element-tracker";
/**
* JSPI coroutine lifecycle in the REAL editor successor to
* fiber-resume-park.spec.ts (which pinned the retired Asyncify rewind guard;
* its beacon string `fiber-resume-refused` no longer exists, making its
* engagement assert vacuous).
*
* The prod-shaped gate for the August 2026 ownership bug: coroutine.h's
* ~CALL_CONTEXT released a BORROWED context record (the live enterer of a
* nested dispatch); the JSPI backend read that as destroy-while-parked,
* killed the record, and the poisoned caller slot made PCB_SELECTION_TOOL's
* first Wait() dereference the raw -1 refusal: "coroutine 1 entry REJECTED:
* memory access out of bounds" at boot, then a "[wx-scheduler] job tick
* error" per tool activation and no dialog ever opening. This walks
* boot board load Place Footprints chooser opens Cancel chooser
* closes, asserting a zero ghost/deadParked census and no rejection/trap
* lines at every stage. Deterministically RED on the pre-fix build.
*
* (The old spec's mid-park-resume staging lives on as the jspi-coroutine
* standalone harness, 18 protocol cases in both engines the doc-15
* refusal, destroy-while-parked containment, and the phantom-release
* refusals are pinned there, against the same libcontext.cpp.)
*/
const TRAP_SIGNATURE =
/Aborted\(|index out of bounds|unreachable executed|indirect call signature|null function or function signature|memory access out of bounds|entry REJECTED|job tick error/;
interface CoroCensus {
ghosts: number;
deadParked: number;
refusedResumes: number;
quarantines: number;
parkedCoroutines: string[];
}
function census(page: Page): Promise<CoroCensus> {
return page.evaluate(() => {
const L = (globalThis as any).__libctxJspi;
const S = (globalThis as any).__wxScheduler;
const ring: [number, string, string, number][] = S?._ring ?? [];
return {
ghosts: L?.ghosts ?? -1,
deadParked: L?.deadParked ?? -1,
refusedResumes: ring.filter((r) => r[1] === "libctxRefusedResume").length,
quarantines: ring.filter((r) => r[1] === "libctxQuarantine").length,
parkedCoroutines: [...(S?._suspended?.keys?.() ?? [])].filter((k: string) =>
String(k).startsWith("lc"),
),
};
});
}
// The footprint chooser is a wxFrame, not a wxDialog — count top-level frames
// (same detection as footprint-chooser-close.spec.ts).
function frameCount(page: Page): Promise<number> {
return page.evaluate(
() =>
(window.wxElementRegistry?.findAll({ visible: true }) ?? []).filter((e) =>
/Frame$/.test(e.typeName || ""),
).length,
);
}
// Synthetic emscripten mouse events on the canvas: a Playwright click is
// intercepted by the wx scrollbar overlay (same helper as
// footprint-chooser-close.spec.ts).
async function synthClick(page: Page, x: number, y: number): Promise<void> {
await page.evaluate(
([cx, cy]) => {
const c = document.querySelector("#canvas") as HTMLCanvasElement;
const opt = (b: number) => ({
clientX: cx,
clientY: cy,
bubbles: true,
cancelable: true,
view: window,
button: 0,
buttons: b,
});
c.dispatchEvent(new MouseEvent("mousemove", opt(0)));
c.dispatchEvent(new MouseEvent("mousedown", opt(1)));
c.dispatchEvent(new MouseEvent("mouseup", opt(0)));
c.dispatchEvent(new MouseEvent("click", opt(0)));
},
[x, y],
);
}
test.describe("JSPI coroutine lifecycle (prod-shaped)", () => {
test("boot, board load and tool activation stay coroutine-clean; chooser opens and cancels", async ({
page,
testLogger,
}) => {
test.setTimeout(240000);
await page.goto("/kicad/pcbnew.html");
await waitForPcbnew(page);
const atBoot = await census(page);
console.log(`[TEST] boot census: ${JSON.stringify(atBoot)}`);
expect(atBoot.ghosts, "no ghost/refused transitions at boot").toBe(0);
expect(atBoot.deadParked, "no coroutine died parked at boot").toBe(0);
expect(
atBoot.parkedCoroutines.length,
"the always-on selection tool is parked in Wait()",
).toBeGreaterThan(0);
// The board load is the historical trigger surface (SetBoard →
// ResetTools(MODEL_RELOAD) ×2 → wake/dispatch storm over the parked
// selection tool — where the phantom release fired).
await loadBoard(page, testLogger);
const afterLoad = await census(page);
console.log(`[TEST] after-load census: ${JSON.stringify(afterLoad)}`);
expect(afterLoad.ghosts, "no ghost transitions across the board load").toBe(0);
expect(afterLoad.deadParked, "no coroutine died across the board load").toBe(0);
// Place Footprints via the menu, then a canvas click opens the chooser
// (the pre-fix build swallowed the activation: no dialog, job tick OOB).
const framesBefore = await frameCount(page);
expect(await clickMenuBarItem(page, "Place"), "Place menu findable").toBe(true);
await clickMenuItemByText(page, "Place Footprints");
const canvas = (await page.locator("#canvas").boundingBox())!;
await synthClick(page, Math.round(canvas.width * 0.35), Math.round(canvas.height * 0.45));
await expect
.poll(() => frameCount(page), { timeout: 40000, intervals: [200] })
.toBeGreaterThan(framesBefore);
const chooserOpen = await census(page);
console.log(`[TEST] chooser-open census: ${JSON.stringify(chooserOpen)}`);
expect(chooserOpen.ghosts, "no ghost transitions opening the chooser").toBe(0);
expect(chooserOpen.deadParked, "no coroutine died opening the chooser").toBe(0);
// Cancel the quasimodal. NOTE: in the harness the chooser's library
// enumeration stays parked on its `fp-lib` bridge wait forever (the page
// installs no `window.kicadLibs` provider), so the CLOSE itself is not
// assertable here — the same reason footprint-chooser-close.spec.ts
// soft-waits it. The live app (with a provider) closes on Cancel — probed
// as part of the 2026-08-13 fix verification. What IS assertable, and
// what the pre-fix build fails: the census stays clean and the app stays
// responsive across the whole exercise.
const cancel = await page.evaluate(() => {
const btn = (window.wxElementRegistry?.findAll({ visible: true }) ?? []).find(
(e) => /Button/i.test(e.typeName || "") && /cancel/i.test(e.label || ""),
);
return btn ? { x: btn.centerX, y: btn.centerY } : null;
});
expect(cancel, "Cancel button found in the chooser").not.toBeNull();
await synthClick(page, cancel!.x, cancel!.y);
await expect
.poll(() => frameCount(page), { timeout: 15000, intervals: [200] })
.toBe(framesBefore)
.catch(() =>
console.log(
"[TEST] chooser close not observable without a lib provider (fp-lib park) — soft",
),
);
// Responsiveness after the cancel: a wx timer still gets delivered (the
// doc-19 dead-app class froze the loop here).
const firedBefore = await page.evaluate(() => {
try { return JSON.parse((window as any).Module.kicadTestTimerParkState()).fired as number; }
catch { return -1; }
});
await page.evaluate(() => (window as any).Module.kicadTestArmTimerPark(30, 0));
await expect
.poll(
() =>
page.evaluate(() => {
try { return JSON.parse((window as any).Module.kicadTestTimerParkState()).fired as number; }
catch { return -1; }
}),
{ timeout: 10000, intervals: [100] },
)
.toBeGreaterThan(firedBefore);
const afterCancel = await census(page);
console.log(`[TEST] after-cancel census: ${JSON.stringify(afterCancel)}`);
expect(afterCancel.ghosts, "cancel left no ghost transitions").toBe(0);
expect(afterCancel.deadParked, "cancel killed no coroutine").toBe(0);
const trapLines = [...testLogger.consoleLogs, ...testLogger.errors].filter((l) =>
TRAP_SIGNATURE.test(l),
);
expect(trapLines, "no trap/rejection signature anywhere in the run").toEqual([]);
});
});

View file

@ -1,226 +0,0 @@
import type { Page } from "@playwright/test";
import { test, expect } from "./fixtures";
/**
* Resume-into-asyncify-parked-coroutine repro the DECODED production
* board-load trap (docs/features/async/15-timer-park-repro.md round 3).
*
* A coroutine suspended by a real yield has valid rewind data in its fiber
* struct; one whose body is asyncify-parked inside handleSleep does NOT.
* TOOL_MANAGER cannot tell the difference, so an event arriving during the
* park Resume()s it the swap rewinds the STALE suspension
* finishContextSwitch doRewind "unreachable executed", and the runtime is
* poisoned ("index out of bounds" from every later entry). The
* kicadTestFiberPark* levers (wasm/bindings/fiber_park.h) stage exactly that
* state machine:
*
* start(parkMs) Call + first KiYield valid suspension primed (phase 1)
* prime() legitimate Resume; body parks in emscripten_sleep (phase 2)
* poke() Resume DURING the park the fatal prod operation
*
* This spec asserts the HEALTHY contract: the mid-park poke must be refused
* (null-INVOCATION_ARGS ghost contract), the body must complete its park and
* yield again undisturbed, a post-yield poke must resume it for real, and no
* trap signature may appear anywhere. On a runtime without the libcontext
* guard this is deterministically RED with the prod signature.
*/
const TRAP_SIGNATURE =
/Aborted\(|index out of bounds|unreachable executed|indirect call signature|null function or function signature|memory access out of bounds/;
type Mod = {
kicadTestFiberParkStart(parkMs: number): boolean;
kicadTestFiberParkPrime(): boolean;
kicadTestFiberParkPoke(): boolean;
kicadTestFiberParkState(): string;
kicadTestFiberParkStartSecond(): boolean;
kicadTestFiberParkPokeSecond(): boolean;
kicadCollabSnapshotItems(): string;
};
interface ParkState {
phase: number;
pokes: number;
parkMs: number;
running: boolean;
phase2: number;
}
async function bootHarness(page: Page): Promise<void> {
await page.goto("/kicad/pcbnew-collab.html");
await expect(page.locator("#canvas")).toBeVisible({ timeout: 90000 });
await page.waitForFunction(() => !!window.wxElementRegistry, null, { timeout: 90000 });
await page.waitForFunction(
() => {
const m = (window as unknown as { Module?: Partial<Mod> }).Module;
return (
typeof m?.kicadTestFiberParkStart === "function" &&
typeof m?.kicadCollabSnapshotItems === "function"
);
},
null,
{ timeout: 90000 },
);
await page.waitForFunction(
() =>
!!window.wxElementRegistry &&
window.wxElementRegistry
.findAll({ visible: true })
.some((e) => /Frame$/.test(e.typeName) || (e.name || "").endsWith("Frame")),
null,
{ timeout: 90000 },
);
}
function parkState(page: Page): Promise<ParkState> {
return page.evaluate(() =>
JSON.parse((window.Module as unknown as Mod).kicadTestFiberParkState()),
);
}
test.describe("Resume() into an asyncify-parked coroutine (libcontext guard)", () => {
test("mid-park resume is refused; the parked body completes undisturbed", async ({
page,
testLogger,
}) => {
test.setTimeout(240000);
await bootHarness(page);
// Phase 1: prime a real suspension (Call + first KiYield). NOTE: embind
// return values are asyncify unwind PLACEHOLDERS for anything that
// crosses a fiber swap (the real return lands in the discarded ghost
// rewind) — every assertion here is on polled state, never on returns.
await page.evaluate(() => {
(window.Module as unknown as Mod).kicadTestFiberParkStart(2000);
});
await expect
.poll(async () => (await parkState(page)).phase, { timeout: 10000, intervals: [50] })
.toBe(1);
// Phase 2: legitimate resume; the body enters its 2s asyncify park.
await page.evaluate(() => {
(window.Module as unknown as Mod).kicadTestFiberParkPrime();
});
await expect
.poll(async () => (await parkState(page)).phase, { timeout: 10000, intervals: [50] })
.toBe(2);
// THE PROD OPERATION: resume while the body is parked. On an unguarded
// runtime this rewinds the stale fiber suspension and traps right here
// (the page's uncaught "unreachable executed"); with the guard it is a
// clean no-op refusal.
await page.evaluate(() => {
(window.Module as unknown as Mod).kicadTestFiberParkPoke();
});
const afterPoke = await parkState(page);
console.log(`[TEST] mid-park poke: ${JSON.stringify(afterPoke)}`);
expect(afterPoke.pokes, "poke reached the coroutine layer").toBe(1);
expect(afterPoke.phase, "refused poke left the parked body undisturbed").toBe(2);
// The park must complete on its own wake and yield again (phase 3) —
// if the poke corrupted the fiber, the wake rewind dies instead.
await expect
.poll(async () => (await parkState(page)).phase, { timeout: 15000, intervals: [100] })
.toBe(3);
// A post-yield poke is a LEGITIMATE resume and must work (the guard must
// not refuse valid suspensions): body runs to completion.
await page.evaluate(() => {
(window.Module as unknown as Mod).kicadTestFiberParkPoke();
});
await expect
.poll(async () => (await parkState(page)).phase, { timeout: 10000, intervals: [100] })
.toBe(4);
// Runtime integrity: a model walk still works and no trap signature
// appeared anywhere in the console.
const snapshot = await page.evaluate(() =>
(window.Module as unknown as Mod).kicadCollabSnapshotItems(),
);
expect(typeof snapshot, "snapshot entry still functional").toBe("string");
const trapLines = [...testLogger.consoleLogs, ...testLogger.errors].filter((l) =>
TRAP_SIGNATURE.test(l),
);
expect(trapLines, "no wasm trap signature anywhere in the run").toEqual([]);
});
test("poisoned attribution: a second coroutine launders the parked fiber; the JS guard still quarantines it", async ({
page,
testLogger,
}) => {
test.setTimeout(240000);
await bootHarness(page);
// Prime + park the first coroutine (same staging as scenario 1).
await page.evaluate(() => {
(window.Module as unknown as Mod).kicadTestFiberParkStart(2500);
});
await expect
.poll(async () => (await parkState(page)).phase, { timeout: 10000, intervals: [50] })
.toBe(1);
await page.evaluate(() => {
(window.Module as unknown as Mod).kicadTestFiberParkPrime();
});
await expect
.poll(async () => (await parkState(page)).phase, { timeout: 10000, intervals: [50] })
.toBe(2);
// THE LAUNDERING: start a second coroutine while the first is parked.
// libcontext attributes this jump's old side to the PARKED fiber
// (g_current_context is stale) — writing a fresh suspension into its
// struct and re-marking it swap_suspended, exactly how the prod resume
// bypassed the C++ guard on v0.1.21.
await page.evaluate(() => {
(window.Module as unknown as Mod).kicadTestFiberParkStartSecond();
});
await expect
.poll(async () => (await parkState(page)).phase2, { timeout: 10000, intervals: [50] })
.toBe(1);
// The fatal prod operation, now with the C++ guard blinded. The JS
// stale-rewind guard must refuse it (quarantine beacon) instead of
// rewinding foreign/stale data.
await page.evaluate(() => {
(window.Module as unknown as Mod).kicadTestFiberParkPoke();
});
const afterPoke = await parkState(page);
console.log(`[TEST] laundered mid-park poke: ${JSON.stringify(afterPoke)}`);
expect(afterPoke.phase, "quarantined poke left the parked body undisturbed").toBe(2);
// The park must still complete on its own wake and yield again.
await expect
.poll(async () => (await parkState(page)).phase, { timeout: 15000, intervals: [100] })
.toBe(3);
// Post-yield resume is legitimate again and completes the first body.
await page.evaluate(() => {
(window.Module as unknown as Mod).kicadTestFiberParkPoke();
});
await expect
.poll(async () => (await parkState(page)).phase, { timeout: 10000, intervals: [100] })
.toBe(4);
// The second coroutine also completes cleanly.
await page.evaluate(() => {
(window.Module as unknown as Mod).kicadTestFiberParkPokeSecond();
});
await expect
.poll(async () => (await parkState(page)).phase2, { timeout: 10000, intervals: [100] })
.toBe(2);
// Window-engagement proof: the JS guard must have actually refused the
// laundered resume — silence means the scenario never bypassed the C++
// guard and the test is vacuous.
const refusals = testLogger.consoleLogs.filter((l) =>
l.includes("fiber-resume-refused"),
);
console.log(`[TEST] refusal beacons: ${refusals.length}`);
for (const l of refusals.slice(0, 4)) console.log(`[TEST] ${l}`);
expect(refusals.length, "the stale-rewind guard intercepted the laundered resume").toBeGreaterThan(0);
const trapLines = [...testLogger.consoleLogs, ...testLogger.errors].filter((l) =>
TRAP_SIGNATURE.test(l),
);
expect(trapLines, "no wasm trap signature anywhere in the run").toEqual([]);
});
});

View file

@ -58,20 +58,36 @@ async function synthClick(page: Page, x: number, y: number): Promise<void> {
}
async function assertResponsive(page: Page, label: string): Promise<void> {
const before = await page.evaluate(
() => Number((window.__wxAsyncifyDump?.().match(/fcsTotal=(\d+)/) || [])[1] || 0),
);
await page.waitForTimeout(1500); // eslint-disable-line -- sampling the loop counter across a fixed window
const after = await page.evaluate(
() => Number((window.__wxAsyncifyDump?.().match(/fcsTotal=(\d+)/) || [])[1] || 0),
);
if (after === before) {
const dump = await page.evaluate(() =>
typeof window.__wxAsyncifyDump === 'function' ? window.__wxAsyncifyDump() : 'no dump',
);
console.log(`[TEST] RECORDER after ${label} (loop STALLED, fcs=${after}):\n${dump}`);
// JSPI liveness metric: a wx timer firing IS the doc-19 liveness semantic
// (the dead-app class = the event loop stops delivering). Arm the
// parking-timer lever with parkMs=0 (fires, no park; `fired` is a
// cumulative counter, so re-arming per call is fine) and poll for the
// increment. Engine-neutral, unlike scheduler wait counters, which sit
// still on an idle Firefox loop. (The asyncify-era fcsTotal retired with
// that scheduler.)
const fired = () =>
page.evaluate(() => {
const m = (window as any).Module;
try { return JSON.parse(m.kicadTestTimerParkState()).fired as number; }
catch { return -1; }
});
const before = await fired();
await page.evaluate(() => (window as any).Module.kicadTestArmTimerPark(30, 0));
let after = before;
for (let i = 0; i < 40 && after <= before; i++) {
await page.waitForTimeout(100); // eslint-disable-line -- polling the timer heartbeat
after = await fired();
}
expect(after, `main loop still advancing after ${label}`).toBeGreaterThan(before);
if (after <= before) {
const dump = await page.evaluate(() => {
const w = window as any;
return typeof w.__wxWaitDump === 'function'
? JSON.stringify(w.__wxWaitDump())
: 'no dump';
});
console.log(`[TEST] RECORDER after ${label} (loop STALLED, fired=${after}):\n${dump}`);
}
expect(after, `wx timer still delivered after ${label}`).toBeGreaterThan(before);
}
test.describe('Add Footprint chooser close (doc-19 dead-app repro)', () => {

View file

@ -298,21 +298,22 @@ test.describe("quasi-modal strand (doc 19)", () => {
expect(await dialogCount(page)).toBeGreaterThan(0);
await okButtonCenter(page);
// RE-PINNED AT THE FLIP (docs/features/async/22 §10, 2026-08-08). The
// overlap this staging proved (a timer park on top of an open-ended park)
// required an in-place park for the timer to land on; post-flip every
// party is a scheduler context and D5 removed the main loop's in-place
// park, so the window is structurally impossible. The staging now pins
// the post-migration invariant: the dialog opens, the timer fires and its
// park survives (asserted above), and NO concurrent-park window is
// observable.
// RE-PINNED AT THE FLIP (docs/features/async/22 §10, 2026-08-08), and
// RE-KEYED for JSPI (2026-08-13): the `[wx-asyncify] concurrent-park|…`
// beacons retired with the asyncify scheduler, which made the old filter
// vacuous. The post-migration invariant is the same — the dialog opens,
// the timer fires and its park survives (asserted above) — and the
// observable JSPI failure modes of an overlap are ghost/refused
// transitions, a stuck-window force-clear, or a job-tick trap.
const overlapBeacons = testLogger.consoleLogs.filter((l) =>
/\[wx-asyncify\] (concurrent-park|aliased-wake-live|overlapped-wake)/.test(l),
/\[libctx-jspi\] ghost\/refused transition|\[wx-scheduler\] (force-clearing stuck window|job tick error)/.test(
l,
),
);
console.log(`[STRAND] staging overlap beacons: ${overlapBeacons.length}`);
expect(
overlapBeacons.length,
"no concurrent-park window is observable post-flip",
"no ghost/stuck-window/job-tick anomaly is observable post-flip",
).toBe(0);
});

View file

@ -82,12 +82,32 @@ export async function installNgspiceServiceStub(page: Page): Promise<void> {
workerP = null;
try { worker.terminate(); } catch { /* already gone */ }
};
// Legible boot: bound the handshake and surface worker
// death — the bare version hung to the spec timeout with
// zero evidence (occ-service.ts has the same guard).
await new Promise<void>((resolve, reject) => {
const fail = (msg: string) => {
clearTimeout(timer);
reject(new Error(msg));
};
const timer = setTimeout(
() => fail('[TEST-NGSPICE] ngspice_service boot timed out after '
+ '60s (no ready/bootError from the worker)'), 60000);
const onFirst = (e: MessageEvent) => {
if (e.data?.ready) { worker.removeEventListener('message', onFirst); resolve(); }
else if (e.data?.bootError) reject(new Error(e.data.bootError));
if (e.data?.ready) {
worker.removeEventListener('message', onFirst);
clearTimeout(timer);
resolve();
} else if (e.data?.bootError) {
fail(`[TEST-NGSPICE] ngspice_service bootError: ${e.data.bootError}`);
}
};
worker.addEventListener('message', onFirst);
worker.addEventListener('error', (e: any) => fail(
`[TEST-NGSPICE] ngspice_service worker error: ${e?.message ?? e} `
+ `(${e?.filename ?? '?'}:${e?.lineno ?? '?'})`));
worker.addEventListener('messageerror', () => fail(
'[TEST-NGSPICE] ngspice_service worker messageerror (structured clone failed)'));
});
console.log('[TEST-NGSPICE] ngspice_service ready');
return worker;

View file

@ -63,12 +63,34 @@ export async function installOccServiceStub(page: Page): Promise<void> {
const resolve = pending.get(id);
if (resolve) { pending.delete(id); resolve(res); }
};
// Legible boot: the old handshake could never reject on a
// worker DEATH (importScripts throw, pthread spawn wedge,
// OOM-kill) — the promise just hung until the spec's 180s
// timeout with zero evidence. Surface worker errors and
// bound the boot.
await new Promise<void>((resolve, reject) => {
const fail = (msg: string) => {
clearTimeout(timer);
reject(new Error(msg));
};
const timer = setTimeout(
() => fail('[TEST-OCC] occ_service boot timed out after 60s '
+ '(no ready/bootError from the worker)'), 60000);
const onFirst = (e: MessageEvent) => {
if (e.data?.ready) { worker.removeEventListener('message', onFirst); resolve(); }
else if (e.data?.bootError) reject(new Error(e.data.bootError));
if (e.data?.ready) {
worker.removeEventListener('message', onFirst);
clearTimeout(timer);
resolve();
} else if (e.data?.bootError) {
fail(`[TEST-OCC] occ_service bootError: ${e.data.bootError}`);
}
};
worker.addEventListener('message', onFirst);
worker.addEventListener('error', (e: any) => fail(
`[TEST-OCC] occ_service worker error: ${e?.message ?? e} `
+ `(${e?.filename ?? '?'}:${e?.lineno ?? '?'})`));
worker.addEventListener('messageerror', () => fail(
'[TEST-OCC] occ_service worker messageerror (structured clone failed)'));
});
console.log('[TEST-OCC] occ_service ready');
return worker;

View file

@ -51,7 +51,7 @@ const FAMILY_PATTERNS: Record<
openSettleFailed: /\[open\] load chain never settled/,
// JSPI-era families (jspi-scheduler.js + libcontext's JSPI backend):
wxScheduler:
/\[wx-scheduler\] (force-clearing stuck window|mailbox tick error|untracked promising entry|activation stack imbalance|resume window misnested)/,
/\[wx-scheduler\] (force-clearing stuck window|job tick error|untracked promising entry|activation stack imbalance|resume window misnested)/,
libctxJspi: /\[libctx-jspi\] ghost\/refused/,
};