You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(wasm): isolate tree-sitter parsing in worker thread (#965) (#975)
* fix(wasm): isolate tree-sitter parsing in worker thread (#965)
The WASM grammar can trigger uncatchable V8 fatal errors that kill
whichever thread runs it. Running parses in a worker_threads worker
means the crash kills only the worker — the pool detects the exit,
marks the in-flight file as skipped, respawns the worker, and
continues with the rest of the build.
- wasm-worker-entry.ts: worker entry that owns all tree-sitter WASM
calls; runs extractor + AST visitor walk before tree.delete() so
the main thread never holds a live Tree
- wasm-worker-pool.ts: single-worker pool with crash-respawn logic
- wasm-worker-protocol.ts: typed message protocol with serializable
ExtractorOutput (no _tree field)
- parser.ts: route WASM parses through the worker pool
- tests/parsers/wasm-hardening.test.ts: coverage for skip-and-continue
behavior on extractor errors
docs check acknowledged: internal plumbing only — no new CLI surface,
no new language support, no architectural tier changes visible to users
Impact: 80 functions changed, 30 affected
* fix(wasm): resolve worker entry from dist, add timeout, fix tests (#975)
The worker pool previously tried to load the worker entry from src/*.ts
under Node's strip-types runtime, but Node's worker_threads loader does
not rewrite .js import specifiers to .ts — so the worker exited with
"module not found" for every file, breaking all WASM engine tests and
the engine-parity CI jobs.
Changes:
- wasm-worker-pool.ts: resolveWorkerEntry now always points at the
compiled .js. If the sibling .js exists (dist build) use it; otherwise
walk up to dist/domain/wasm-worker-entry.js (tests/dev from src/).
Throws a clear error instead of silently crashing the worker.
- wasm-worker-pool.ts: add per-job timeout (60s) so a hung WASM grammar
(infinite loop instead of crash) can no longer stall the whole build;
remove dead `workerReady` field and its no-op reset in onExit.
- wasm-worker-entry.ts: add a gated test-crash hook
(CODEGRAPH_WASM_WORKER_TEST_CRASH=1 + magic token in code) so we can
unit-test pool crash recovery without a real V8 abort. Remove dead
`shutdown` message handler — the pool uses Worker.terminate() directly.
- wasm-worker-protocol.ts: drop unused WorkerShutdownRequest.
- tests/parsers/wasm-hardening.test.ts: rewrite. The old tests mutated
jsEntry.extractor on the main-thread registry, but the worker has its
own independent registry in a separate V8 isolate, so the mock was
never exercised. New tests use the worker-side crash hook to verify
single-file skip+warn, batch skip-and-continue, and repeated-crash
recovery with worker respawn.
Impact: 10 functions changed, 10 affected
* fix(wasm): dispose parser pool on CLI shutdown to prevent hang (#975)
Impact: 1 functions changed, 1 affected
* fix: guard onExit against stale timed-out job in wasm worker pool (#975)
Impact: 5 functions changed, 9 affected
0 commit comments