fix(vscode): keep worker teardown races out of notifications - #31
Conversation
Two intermittent error notifications traced to the rstest worker's child-process 'error' handler, which treated every 'error' event as a spawn failure the user must fix: - "write EPIPE": a birpc message racing the worker's death. send() was called without a callback, so a lost race became an 'error' event and a notification. Pass a callback and log instead — the 'exit' handler already owns reporting an exit nobody asked for. - "spawn node ENOENT": Node blames the executable when it is the spawn cwd that is gone (a project directory deleted under a live master by a branch switch or a build wiping fixtures). That is a stale-project state detection will reconcile, not a broken runtime: log the real cause, skip the notification and the crashed status. A genuine spawn failure with the cwd intact — the wrong-nodeExecutable case the notification exists for — keeps notifying. Post-spawn 'error' events are absorbed, matching LanguageServerProcessOwner's shape in the lint/fmt stacks.
a53d7bc to
9b68aae
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9b68aaee6a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Two review findings on the pre-spawn guard: - The guard ran after package resolution, so a deleted project directory was first misread as "@rstest/core is not installed" (or notified for a rstestPackagePath inside it). It now sits directly after the disposed fast-fail, before any resolution. - existsSync also returns false for a cwd hidden by a permission failure (EACCES on it or an ancestor), which would have absorbed a genuine, user-actionable spawn failure. The check now stats the cwd and treats only ENOENT/ENOTDIR as "really not there".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f643b0ea49
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The test awaited the child's 'spawn' event from a listener attached after createChildProcess() resolved; Node gives no timing guarantee for 'spawn' relative to that continuation, so a prompt emit could leave the promise pending until the suite timeout. Await the child's first stdout chunk instead: stream data is buffered until a listener attaches, and 'spawn' — which sets the handler's latch — precedes all other events.
Summary
Two intermittent error notifications traced to the rstest worker's child-process
errorhandler, which treated everyerrorevent as a spawn failure the user must fix:write EPIPE— a birpc message losing the race against the worker's death (cancel a run, a config-change refresh disposing a running worker, or the worker crashing on its own).send()was called without a callback, so Node turned the lost race into a processerrorevent and a notification.send()now takes a callback: the failure is logged, and theexithandler keeps owning the report of an exit nobody asked for.spawn node ENOENT— Node blames the executable when it is the spawn cwd that is gone (a project directory deleted under a live master by a branch switch,git clean, or a build wiping fixtures). A pre-spawn guard now fails fast with the real cause and no notification — a stale project is a state detection reconciles, not a runtime the user must fix. Theerrorhandler keeps the same check as a fallback for the delete-after-check race.A genuine spawn failure with the cwd intact — the wrong-
nodeExecutablecase the notification exists for — still notifies and still latches thecrashedstatus. Post-spawnerrorevents are absorbed, matching the shape the lint/fmt stacks already use.Related Links
Checklist