Skip to content

test(portal): wait for an unrelated child's READY and exit past a loaded runner's start, not 2 s - #2409

Merged
devswha merged 1 commit into
mainfrom
test/portal-child-start-wait
Oct 29, 2026
Merged

devswha merged 1 commit into
mainfrom
test/portal-child-start-wait

Conversation

@devswha

@devswha devswha commented Oct 29, 2026

Copy link
Copy Markdown
Owner

Found by the flake-hunt lane, from a Dori pin. server/portal.test.ts "running Portal > does not treat an arbitrary interpreter as a Portal script" timed out at about 2.0 s ("Timed out: unrelated interpreter executed its script") in five local check fast runs across four lanes:

  • feat-relay-service, twice;
  • feat-chat-comment-on-selection;
  • refactor-socket-like;
  • feat-relay-mux-codec.

It failed at a host load of about 70 and passes alone.

Cause (test flake)

The case starts a stand-in Bun process (process.execPath <script>) and waits for its READY line on stdout. The signal is right, but the wait raced it against 2 s of wall clock, and a loaded host can take longer than that to start a Bun process.

Change

  • Child waits: a child process starting or stopping is still waited for by its own signal, its READY line or its exit. The bound (CHILD_MS, 20 s) only names a child that hangs. It is far above any start time and below the case's own 30 s timeout.
  • Which cases: the interpreter case and the shell case next to it, which spawns sh with the same pattern and the same 2 s bound but has not failed yet.
  • Unchanged: the other bounded and until waits in the file, which watch the service's own state rather than a process start.

Proof

  • Fail-first: with a scratch 2.5 s sleep before READY, the old test failed 2/2 with CI's "Timed out: unrelated interpreter executed its script", and the new one passed 3/3.
  • Plain runs: bun test server/portal.test.ts passed 5/5 (38 tests).
  • Local checks: bun run check fast ok.

Test-only.

Review

omo-native-code-reviewer: APPROVE (CLEAR). It confirmed that both cases wait on an exact signal, the READY line or the exit, and that the 30 s case timeout is required: Bun's 5 s default would cut a slow start off first. It found no clearly better injection: the case needs a real non-shell interpreter, because portal.ts treats only sh-family shells as script runners, and process.execPath is the only interpreter guaranteed to be installed.

  • LOW, fixed: the comment over-claimed "far above any start time", and the case timeout is now derived (CASE_MS = CHILD_MS + 10_000).
  • LOW, fixed: the changelog wording.
  • Follow-up note, not changed: other 2 s waits in the file also involve a real /bin/sh, and none has failed.
    • Waits that include the portal version start: :407, :811, :904, :971 and :1128.
    • bounded(service.shutdown()) exit waits: :189, :242, :489 and others. Portal's own SIGKILL fallback comes after 4 s.
    • The same constant fits them if they ever flake.

Test-only, so no Codex review (notes/pr-policy.md).

…ded runner's start, not 2 s

"running Portal > does not treat an arbitrary interpreter as a Portal script"
starts a stand-in Bun process and waits for its READY line, racing it against
a 2 s bound. On a host at load ~70 a Bun start takes longer: it timed out at
~2.0 s five times in local check fast runs across four lanes.

The wait stays on the child's own signal (READY, exit); the bound (CHILD_MS,
20 s) only names a hung child, under the case's own timeout (CASE_MS). The
shell case next to it, with the same pattern, gets the same.

Fail-first with a scratch 2.5 s sleep before READY: old 2/2 timed out, new
3/3 passed. portal.test.ts passed 5/5 (38 tests); bun run check fast ok.
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Increased the time allowed for two Portal tests to start and finish their child processes, reducing failures when those processes take longer to respond.

Two Portal unit tests now allow up to 20 seconds for spawned processes to start and terminate. Each test has a 30-second limit. A changelog entry records the change.

Changes: Portal child-process test timeouts

Layer / File(s) Summary
Configure bounded child-process waits
server/portal.test.ts, changelog.d/unit-flake-portal-child-start.md
The shell-process and interpreter tests use shared 20-second child-process waits and 30-second test limits. The changelog records the increased startup and termination waits.

Priority: Low

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

Change: Other

Possibly related PRs

Suggested reviewers: rabbitson87

Merge Risk: Minimal · up to 52090

The PR only extends bounded waits for two Portal tests and is ready to merge.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly identifies the primary change: extending portal child-process waits beyond the 2-second limit. It is specific and related to the changeset, although somewhat long.
Description check Passed The description explains the failure, cause, affected tests, implementation, unchanged behavior, and validation results. It includes the required Change and Validation information, although skipped ch…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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: Description check

Explanation

The description explains the failure, cause, affected tests, implementation, unchanged behavior, and validation results. It includes the required Change and Validation information, although skipped checks are not explicitly listed.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. 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 0 functions across 1 files. (1 skipped: 1 unsupported.)

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • 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

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 29, 2026

Copy link
Copy Markdown
Owner Author

Merging 52090d4. Test-only flake fix from the flake-hunt lane: the two portal.test.ts cases that start a stand-in Bun child already wait for its own READY line and its exit, but bounded them at the shared 2 s, which a loaded runner can exceed just starting Bun (5 local failures at load ~70). The child bound is now 20 s (it only names a hung child) with a case timeout above it; the signals waited for are unchanged. Diff read by the merge pass; test-only, so no CodeRabbit review needed.

@devswha
devswha merged commit 46cfce4 into main Oct 29, 2026
19 checks passed
@devswha
devswha deleted the test/portal-child-start-wait branch October 29, 2026 23:35
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