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(worker-pool): clear parse timeouts so --full exits promptly (#146)
* fix(worker-pool): clear parse timeouts so --full exits promptly
Promise.race with uncancellable delay() left 120s timers on the event
loop after workers finished. Replace with explicit setTimeout +
clearTimeout on worker response and dispose.
* test(worker-pool): subprocess exit guard for timer leak
Review follow-up: in-process wall time did not catch orphaned event-loop
timers. Spawn a child that runs parseFilesParallel and assert it exits in
<5s. Export INLINE_PARSE_MAX for fixture gate; remove unused delay().
* test(worker-pool): fail fast when subprocess hangs on timer leak
Race child exit against 6s and kill on hang so regressions fail with a
clear assertion instead of burning the full test timeout.
* test(ci): tighten exit-delay guards
Drop redundant 5s elapsed assertion; hang race is the regression signal.
Wrap Node dist --full smoke in timeout 45 so a timer leak fails CI fast.
* test(worker-pool): address review nits before merge
Stop exporting INLINE_PARSE_MAX; mirror the threshold in tests. Add
node dist --full subprocess exit regression (skips when dist/ absent).
Fix `codemap --full` (and other worker-pool parses) appearing to hang ~120s after stats print — clear parse timeout timers when workers respond instead of leaving orphaned `setTimeout` handles on the event loop.
Copy file name to clipboardExpand all lines: docs/architecture.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -771,7 +771,7 @@ The full rebuild (`--full`) applies several optimizations that are not safe for
771
771
772
772
### Worker thread parallelism
773
773
774
-
File I/O and parsing dominate full rebuild time. The indexer spawns N worker threads (capped at CPU count, min 2, max 6; override **`CODEMAP_PARSE_WORKERS`**, max 32) via `parse-worker.ts`. Each worker receives a chunk of file paths, reads files from disk, and runs the appropriate parser (oxc-parser, lightningcss, or regex). Per-file parse budget: **`CODEMAP_PARSE_TIMEOUT_MS`** when set, else 10s + ~1ms per 50KB file size capped at 30s (`parse-timeout.ts`). Workers recycle after **`CODEMAP_WORKER_RECYCLE_EVERY`** files (default 250) to limit memory growth. Timeouts and other per-file failures append to `<state-dir>/errors.log` without aborting the run. Workers return structured `ParsedFile` results to the main thread, which handles import resolution and database inserts serially.
774
+
File I/O and parsing dominate full rebuild time. The indexer spawns N worker threads (capped at CPU count, min 2, max 6; override **`CODEMAP_PARSE_WORKERS`**, max 32) via `parse-worker.ts`. Each worker receives a chunk of file paths, reads files from disk, and runs the appropriate parser (oxc-parser, lightningcss, or regex). Per-file parse budget: **`CODEMAP_PARSE_TIMEOUT_MS`** when set, else 10s + ~1ms per 50KB file size capped at 30s (`parse-timeout.ts`); multi-file worker messages cap the sum at 120s. `worker-pool.ts` clears the parse timeout when the worker responds (or on `dispose`) so the process does not wait on orphaned timers after indexing finishes. Workers recycle after **`CODEMAP_WORKER_RECYCLE_EVERY`** files (default 250) to limit memory growth. Timeouts and other per-file failures append to `<state-dir>/errors.log` without aborting the run. Workers return structured `ParsedFile` results to the main thread, which handles import resolution and database inserts serially.
0 commit comments