Skip to content

test(hosts): wait for e2e update processes before deleting their temp directory - #387

Merged
andrebrait merged 5 commits into
ompweb-dev:mainfrom
andrebrait:fix/host-e2e-cleanup
Nov 3, 2026
Merged

andrebrait merged 5 commits into
ompweb-dev:mainfrom
andrebrait:fix/host-e2e-cleanup

Conversation

@andrebrait

@andrebrait andrebrait commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Failure

Windows CI on #385 reports 2449 passed tests, zero failed tests, then an unhandled EBUSY in lib/hosts/host-update-e2e.test.mjs cleanup. The after hook sends termination signals then removes the directory immediately.

Fix

Track each test-owned child, actual old daemon and detached worker from status, and launched hosts via the existing fixture PID ledger. Register the original daemon immediately, before startup can fail. Wait for all recorded live processes to stop before removing the directory. Linux zombies already released handles, so they count as stopped. Ignore only ESRCH when terminating. Retry bounded transient directory-removal errors because Bun ignores rmSync retry options.

Only the e2e test changes; production behavior and all update assertions remain intact. No test skips or swallowed unexpected failures. No changelog entry for this internal test-only repair.

Verification

Real success and rollback update scenarios: 2 pass on Linux, including final cleanup. Full suite: 2475 pass, 12 skip, 0 fail. ESLint and typecheck pass. One adversarial review completed; its cleanup-ownership, zombie and termination-error findings are addressed. Windows confirmation remains for CI.

Summary by CodeRabbit

  • Tests
    • Improved reliability of end-to-end host update tests by tracking processes started during test runs and centralizing their cleanup. The tests verify process command lines before attempting termination and wait for processes to stop. Temporary directory cleanup now retries for selected filesystem errors, helping prevent leftover processes or files from affecting subsequent test runs.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
Walkthrough

The host update end-to-end test records process IDs from its fixtures and spawned children. Centralized teardown checks process command lines, terminates test-owned processes, waits for exit, and retries temporary-directory removal for selected filesystem errors.

Changes: Host update test process cleanup

Layer / File(s) Summary
Record update processes
lib/hosts/host-update-e2e.test.mjs
The test registers update status files and spawned children for teardown. Its release fixtures provide a host PID file path, and the generated daemon appends its PID to that file.
Clean up recorded processes
lib/hosts/host-update-e2e.test.mjs
Centralized teardown gathers recorded PIDs and terminates them only when their command lines identify the test’s temporary directory. It waits for processes to exit, treats Linux zombies as not alive, and retries directory removal for selected filesystem errors. The per-attempt SIGTERM callback was removed.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Merge Risk: Low · previous review ef5d6

Cleanup can leave a test-owned process running when identity lookup fails, potentially preserving the Windows directory-removal failure. Retry verification or report the unresolved process; otherwise the remaining merge risk is bounded.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: waiting for end-to-end update processes before removing their temporary directory.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 1 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the PID trail,
Then waits until each process rests.
The temp files find their way out,
While cleanup tries again when busy.
The host update test ends neat.

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
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: 00061ed4-1009-4b34-a538-d93e6468ba6c
Commits

Reviewing files that changed from the base of the PR and between 0a5201f and ef5d68e.

Files selected for processing: 2
  • graphify-out/graph.json
  • lib/hosts/host-update-e2e.test.mjs

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

Recent review details
Additional context used
Code guidelines: 3
docs/specs/2026-10-28-remote-hosts-design.md — auto-discovered
docs/specs/2026-10-29-local-daemon-design.md — auto-discovered
AGENTS.md — auto-discovered
Path-based instructions: 5
Applicability reference: AGENTS.md: # omp-web - Development Notes **Link = one WebSocket per host, dialled by the daemon** (`/api/hosts/link`; design `docs/specs/2026-10-31-websocket-link-design.md`).

CodeRabbit inference engine (docs/specs/2026-10-28-remote-hosts-design.md)

Files:

  • lib/hosts/host-update-e2e.test.mjs
Applicability reference: AGENTS.md: # omp-web - Development Notes Source excerpt: **The local daemon is required.**

CodeRabbit inference engine (docs/specs/2026-10-29-local-daemon-design.md)

Files:

  • lib/hosts/host-update-e2e.test.mjs
Source excerpt: **Edit** (`edit_message`, user-message button): moves the live conversation's history to before that user entry; it is not a read-only historical view or an explicit Fork.

CodeRabbit inference engine (AGENTS.md)

Files:

  • lib/hosts/host-update-e2e.test.mjs
Source excerpt: **Daemon-loaded modules must not import `@/` or use Bun APIs.**

CodeRabbit inference engine (AGENTS.md)

Files:

  • lib/hosts/host-update-e2e.test.mjs
Source excerpt: `server/routes.test.ts` fails when the table and the files on disk differ, and when a route module exports anything but method handlers.

CodeRabbit inference engine (AGENTS.md)

Files:

  • lib/hosts/host-update-e2e.test.mjs

@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 (2 files)
  • graphify-out/graph.json - Binary/generated file, skipped per review policy
  • lib/hosts/host-update-e2e.test.mjs - 3 lines added; cleanup hardening fix, no issues
Previous Review Summaries (6 snapshots, latest commit bf9e43f)

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

Previous review (commit bf9e43f)

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 (19 files)
  • AGENTS.md
  • CHANGELOG.md
  • app/api/uploads/[id]/route.ts
  • components/ChatInput.tsx
  • components/ChatInput.uploads.test.mjs
  • docs/specs/2026-11-02-file-uploads-design.md
  • graphify-out/graph.json
  • lib/browser-link.test.mjs
  • lib/browser-link.ts
  • lib/event-stream-worker.test.mjs
  • lib/event-stream-worker.ts
  • lib/event-stream.test.mjs
  • lib/event-stream.ts
  • lib/hosts/daemon.test.mjs
  • lib/hosts/daemon.ts
  • lib/hosts/uploads.test.mjs
  • lib/hosts/uploads.ts
  • lib/uploads.test.mjs
  • lib/uploads.ts

Previous review (commit 8cea299)

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)
  • graphify-out/graph.json
  • lib/hosts/host-update-e2e.test.mjs

Previous review (commit ef5d68e)

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)
  • graphify-out/graph.json
  • lib/hosts/host-update-e2e.test.mjs

Previous review (commit 44c305d)

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)
  • graphify-out/graph.json
  • lib/hosts/host-update-e2e.test.mjs

Previous review (commit 0a5201f)

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)
  • graphify-out/graph.json
  • lib/hosts/host-update-e2e.test.mjs

Previous review (commit c6932a8)

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)
  • graphify-out/graph.json
  • lib/hosts/host-update-e2e.test.mjs

Reviewed by free · Input: 352.1K · Output: 41.1K · Cached: 160.3K

@andrebrait

Copy link
Copy Markdown
Collaborator Author

@codex review

@andrebrait

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T10:59:06.033809Z ef5d68e Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: c6932a85a5

ℹ️ 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".

@andrebrait

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread lib/hosts/host-update-e2e.test.mjs Resolved
Comment thread lib/hosts/host-update-e2e.test.mjs Resolved
@andrebrait

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 44c305d5c0

ℹ️ 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".

Comment thread lib/hosts/host-update-e2e.test.mjs Outdated
Comment on lines +29 to +32
for (const pid of pids) {
if (owned.has(pid) || !Number.isSafeInteger(pid) || pid <= 1 || pid === process.pid || !alive(pid)) continue;
const identity = await processStartIdentity(pid);
if (identity) owned.set(pid, identity);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Capture identities when processes write the PID ledger

If a recorded process exits before the next polling pass and its PID is reused, this loop adopts the unrelated replacement's start identity as its own. The rollback "exit" fixture specifically appends its PID immediately before process.exit(4) (hostScript/hostBody in update-fixture.test-helper.mjs), so the ledger can contain already-dead, never-adopted PIDs. The later identity check in after then matches the replacement and sends it SIGTERM, potentially terminating another test or local process. This is separate from the documented check-to-signal race. Record the start identity alongside the PID in the writer, or retain a process handle, rather than deriving ownership from whoever currently holds the recorded PID.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ef5d68e: ownership no longer comes from whoever holds a recorded pid. Every process the test starts runs a script from its unique mkdtemp directory, so the after hook signals a recorded pid only while its command line still names that directory (/proc/<pid>/cmdline, Win32_Process.CommandLine, ps). A reused pid runs something else and is skipped, including the rollback fixture's ledger entry for a host that already exited. The start-identity adoption is removed. Locally both relaunched hosts match and are stopped, with no leftover processes; the remaining check-to-signal window is documented.

@andrebrait

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: ef5d68e8d9

ℹ️ 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".

@andrebrait

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@andrebrait

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread lib/hosts/host-update-e2e.test.mjs Resolved
@andrebrait
andrebrait force-pushed the fix/host-e2e-cleanup branch from 8cea299 to bf9e43f Compare November 3, 2026 13:02
…orary directory

Windows CI passed all tests but the after hook threw EBUSY while deleting a directory still held by a relaunched host. Track shell wrappers, the actual old daemon, detached update worker, and launched hosts. Await termination before removal, treat exited Linux zombies as stopped, and retry only transient filesystem errors. Preserve every update assertion and surface unexpected kill errors.
…ches

CodeRabbit review: a recorded pid can be reused after its process exits. Capture each recorded process start identity while the run is in progress (also on failure or timeout), kill the owned ChildProcess handles directly, and send SIGTERM to a recorded pid only while its identity still matches.
CodeRabbit review: identities were captured only once the update finished, so a process that exited during it could hand its pid to another one first. Capture them on every poll, and document the residual check-then-signal window for pid-only entries.
…ded pid

Codex review: a recorded pid that exited before it was adopted could be reused, and the replacement adopted as ours. Every process the test starts runs a script from its unique temporary directory, so signal a recorded pid only while its command line still names that directory. This replaces the start-identity adoption.
…identified

CodeRabbit review: a failed command-line lookup skipped a live process silently. Retry once, then fail the hook while the process is still alive.
@andrebrait

Copy link
Copy Markdown
Collaborator Author

Merge approved by the user. Main advanced with #389, so I rebased this cleanup-only branch onto it before landing. No cleanup implementation changed. Local full suite: 2499 pass, 12 skip, 0 fail; typecheck passed. Awaiting this head’s CI, then merging with the head SHA pinned.

@andrebrait
andrebrait force-pushed the fix/host-e2e-cleanup branch from bf9e43f to f8342d6 Compare November 3, 2026 17:30
@andrebrait
andrebrait merged commit 854c7c3 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