Skip to content

fix(engine): stop parse workers on failure and interrupt - #428

Draft
vibgrate-team wants to merge 1 commit into
mainfrom
cursor/parse-worker-shutdown-887d
Draft

vibgrate-team wants to merge 1 commit into
mainfrom
cursor/parse-worker-shutdown-887d

Conversation

@vibgrate-team

Copy link
Copy Markdown
Contributor

Summary

vg build and vg scan parse through a worker pool. Two shutdown gaps left that pool unsafe on a bad run:

  • A worker that crashed off the task promise made destroy() throw an uncaught TypeError: emitter.removeListener is not a function, so the process dumped a stack instead of a usable error.
  • A parent that exited on SIGINT, SIGTERM, or process.exit without killing its workers could leave those workers reparented (they show up as stray node processes running tinypool's process entry).

The pool now cancels and destroys workers when parsing finishes, when parsing fails, and on SIGINT/SIGTERM. If destroy() does not finish, workers are killed. Expected failures print one line — what failed, and whether to re-run with --jobs 1, --exclude, or VG_WORKER_HEAP_MB — and vg build surfaces that as a normal error: line. A scan that cannot build the map records the same line and continues. Parse order is still sorted by path, so graph output is unchanged.

Related issues

Closes #301

Checklist

  • pnpm test passes
  • pnpm lint is clean
  • pnpm typecheck is clean
  • Docs updated (README / DOCS / ARCHITECTURE) where behavior changed
  • Determinism preserved — identical input still produces identical graph.json / report output (content-hashed IDs, stable sorts; no time, randomness, or filesystem-order dependence)
  • No proprietary or internal references — public, Apache-2.0 content only
  • Commits use Conventional Commits and are signed off (git commit -s, DCO)

Notes for reviewers

  • Production stays on worker_threads. child_process is covered by the same kill path so a worker that is an OS process cannot outlive the command. The regression harness (test/fixtures/parse-pool-harness.ts) starts a failing and an interrupted pool and asserts the process list is clear afterwards.
  • Workers do not inherit --import, --require, or --inspect, so a loader or debugger port is not a second long-lived Node process. Heap flags such as --max-old-space-size are still passed through.
  • pnpm lint still reports the same five pre-existing unused-variable warnings; this change adds none.
Open in Web Open in Cursor 

A crashed parse worker made pool shutdown throw an uncaught stack, and a
parent that exited without kill left child workers reparented. Stop workers
on failure, SIGINT, SIGTERM, and normal exit, and report a one-line remedy.

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

Co-authored-by: vibgrate-team <vibgrate-team@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: parse-worker failures must exit cleanly without leaving orphan processes

2 participants