Skip to content

test(hosts): fix daemon-update-safety timeout flake blocking #569 - #574

Open
kahme247 wants to merge 1 commit into
mainfrom
fix-daemon-update-safety-flake-2026-11-23
Open

kahme247 wants to merge 1 commit into
mainfrom
fix-daemon-update-safety-flake-2026-11-23

Conversation

@kahme247

@kahme247 kahme247 commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes the lib/hosts/daemon-update-safety.test.mjs flake that fails macOS Verify on #569 (runs 45152468094 and 45179660435): three tests time out at Bun's exact 30s limit when the file runs whole, but pass in ~0.3s in isolation.

Root cause

Two linked test defects, both in this file — no production code changed:

  1. The fixture's fake install is umask-sensitive. updatableInstall creates the fake npm install with mkdirSync, so its mode follows the ambient umask. With a permissive umask (e.g. 0007, as in this VM's shell), the install directory ends up group-writable (0770), and the host's installSupport check (lib/hosts/updates.ts) correctly refuses a group- or world-writable install directory. planHostUpdate then returns early with only the unsupported_install blocker, so the update check's blockedReason is the install reason and the session reason never surfaces.
  2. That failure poisons every later test. In "a session still starting also blocks the update check…", the blockedReason assertion throws before gate.resolve() runs, so the monkey-patched localHost.spawnRpc (which awaits the gate forever) is never restored: start()'s t.after (daemon.stop()) was registered first and hangs on the pending gated spawn, so the restore hook registered after it never executes. Every later test that spawns a session then hits the dead gate — its open is never answered, the 5s until throws, and the hung stop() turns the failure into a 30s Bun timeout. The three victims are "a malformed update status…", "a forced update accepts new sessions while it stages…", and "a forced commit defers automatic recovery…".

Proven locally: with umask 022 the file passes 13/13 in ~1.4s; with umask 0007 it failed 6 pass / 7 fail in 96s before this fix, with the instrumented run showing the held answer carrying the install blockedReason and the gated spawn waiting on a gate that was never resolved.

Fix (test file only)

  • updatableInstall now pins the fixture install directory to 0o755 with chmodSync, so the update check is not decided by whatever umask the runner happens to use.
  • The "a session still starting" test now resolves the gate and restores localHost.spawnRpc in a try/finally, so a failed assertion can no longer leave the gate shut or leak the patched spawnRpc into later tests.

Verification

  • bun test --timeout 30000 lib/hosts/daemon-update-safety.test.mjs: 13 pass / 0 fail, three consecutive runs under umask 0007 (~1.3s each; was 6/7 in 96s).
  • Full lib/hosts/ suite: the file is 13 pass / 0 fail inside it. (The suite run has other failures in unrelated files in this VM — pre-existing environment failures; the parent's earlier full-suite baseline on main also failed in this VM. This change touches only this one file.)
  • npx tsc --noEmit and npx eslint lib/hosts/daemon-update-safety.test.mjs: clean.

Unblocks #569.

Summary by CodeRabbit

  • Tests
    • Improved test cleanup by ensuring the spawn gate is released and the original RPC behavior is restored, even when the test encounters an error.
    • Set the fixture install directory permissions explicitly for more consistent test behavior.

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The daemon update safety test sets explicit permissions on its install fixture. It also releases the spawn gate and restores localHost.spawnRpc in a finally block.

Changes: Daemon update safety test

Layer / File(s) Summary
Configure fixture and restore test state
lib/hosts/daemon-update-safety.test.mjs
The test sets the install directory mode to 0o755. It uses try/finally to release the spawn gate and restore localHost.spawnRpc.

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

Change: Other

Suggested reviewers: andrebrait

Merge Risk: Minimal · up to 5c933

This is a test-only fix that removes an umask-dependent flake and guarantees cleanup of a gated spawn. It has no production behavior change and is low risk to merge.

Security architecture risk: Minimal · up to 5c933

The change makes the daemon update tests independent of the runner’s file-creation settings and prevents a failed assertion from leaving later tests stuck. Production behavior is unchanged.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the test area (hosts), the change type (test), and the specific flake fixed (daemon-update-safety timeout). The summary and objectives confirm the PR pins the fixture install 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: Title check

Explanation

The title names the test area (hosts), the change type (test), and the specific flake fixed (daemon-update-safety timeout). The summary and objectives confirm the PR pins the fixture install directory to mode 0o755 and uses try/finally to restore localHost.spawnRpc, both aimed at that flake. The title is specific and accurate. It cites #569 as the blocked issue, which is context rather than a description of the code change, but this does not make the title misleading.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b5164fd5-0bf3-4697-af15-245d8e123f90
Commits

Reviewing files that changed from the base of the PR and between 67516fb and 5c933ea.

Files selected for processing: 1

  • lib/hosts/daemon-update-safety.test.mjs

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

This branch has not been deployed

No deployments
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