Skip to content

test(hosts): wait for every process the update-worker tests start before removing their temp dir - #383

Merged
andrebrait merged 1 commit into
ompweb-dev:mainfrom
andrebrait:fix/update-worker-leak
Nov 3, 2026
Merged

andrebrait merged 1 commit into
ompweb-dev:mainfrom
andrebrait:fix/update-worker-leak

Conversation

@andrebrait

Copy link
Copy Markdown
Collaborator

Follow-up to #381, which did not fix the Windows EBUSY in lib/hosts/update-worker.test.mjs's after() (main failed the same way on 88ee1c5).

Why #381 did nothing: under Bun, rmSync's maxRetries/retryDelay are ignored. Reproduced on a busy mount: Node retried for ~4 s, Bun threw EBUSY after 0 ms. CI runs bun test.

What held the directory: after() only signalled processes and removed base at once. Worse, daemons the worker launches (detached, unref'd) ran with their cwd inside base and were tracked only through health.json, which a candidate that never acknowledges, or a rollback, never leaves behind.

Change (tests only; update-worker.ts untouched):

  • every fake host appends its pid to a pid file at start, so detached launches are always known;
  • after() signals children, those pids and web.pid, skipping its own pid (a forged-ack health.json holds the runner's), and waits up to 10 s until each is gone;
  • the removal retries itself (50 × 100 ms) since Bun ignores the options;
  • the fixture daemon's cwd is tmpdir(), not a directory inside base.

Linux: 27 pass; 24 processes signalled at teardown, 0 alive before the removal; no /tmp/host-update-worker-* left. Windows is verified by this PR's CI.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 19 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d36c6fb7-7a54-4c07-936c-9a92bafb5be2
Commits

Reviewing files that changed from the base of the PR and between 97468ba and e8f1fc7.

Files selected for processing: 3
  • graphify-out/graph.json
  • lib/hosts/update-fixture.test-helper.mjs
  • lib/hosts/update-worker.test.mjs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@kilo-code-bot

kilo-code-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Code Review Roast 🔥

Verdict: No Issues Found | Recommendation: Merge

Oh wait, this PR is actually clean. I need to sit down. I had my flamethrower warmed up and everything.

📊 Overall: Like finding a unicorn in production — I didn't think clean PRs existed anymore, but here we are.

Files Reviewed (4 files)
  • app/api/files/[...path]/route.ts
  • components/AppShell.tsx
  • components/FileExplorer.tsx
  • components/RightPanel.tsx
Previous Review Summary (commit 7196eef)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 7196eef)

Verdict: No Issues Found | Recommendation: Merge

Oh wait, this PR is actually clean. I need to sit down. I had my flamethrower warmed up and everything.

📊 Overall: Like finding a unicorn in production — I didn't think clean PRs existed anymore, but here we are.

Files Reviewed (2 files)
  • lib/hosts/update-fixture.test-helper.mjs
  • lib/hosts/update-worker.test.mjs

Reviewed by free · Input: 28.6K · Output: 1.8K · Cached: 166K

…ore removing their temp dir

On Windows the update-worker test's after() hook failed with EBUSY on
rm 'host-update-worker-XXXX' even with the maxRetries added in #381.

Two causes, both in teardown:
- Bun's fs.rmSync ignores maxRetries/retryDelay (verified: a bind-mounted
  dir fails with EBUSY after 0 ms under bun, after the full backoff under
  node), so the retries never ran.
- after() only signalled processes and went straight to rmSync. A killed
  Windows process keeps its cwd and handles until it is gone, and the
  detached daemons the worker launches (cwd inside `base`) were known only
  by the pid in health.json, which candidates that never acknowledged do
  not write.

Now each fake host appends its pid to a pidfile on its first line (the
fake manager's web already had one), after() signals every recorded pid
plus the stand-ins and waits (10 s) until each is gone, then removes
`base` with its own retry loop. The descriptor's daemon cwd is the OS tmp
dir instead of a directory inside `base`, since no test depends on it.
@andrebrait

Copy link
Copy Markdown
Collaborator Author

Rebased onto main after #379, which fixed the same EBUSY a narrower way (waits for children and hosts that wrote health.json, keeps rmSync's retry options). This PR keeps #379's intent and widens it: every fake host records its pid even when it never acknowledges, the wait covers those and the fake manager's web, the removal retries in its own loop because Bun ignores maxRetries/retryDelay, and launched hosts no longer run with their cwd inside the temp dir. Windows passed clean (2445 pass, 0 fail, 0 errors) before the rebase.

@andrebrait
andrebrait force-pushed the fix/update-worker-leak branch from 7196eef to e8f1fc7 Compare November 3, 2026 08:34
@andrebrait
andrebrait merged commit a1e7fef into ompweb-dev:main Nov 3, 2026
5 checks passed
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.

1 participant