Skip to content

test(runtime): stop a log-flush race failing the macOS release build - #136

Merged
GeiserX merged 1 commit into
mainfrom
fix/native-log-race
Sep 13, 2026
Merged

GeiserX merged 1 commit into
mainfrom
fix/native-log-race

Conversation

@GeiserX

@GeiserX GeiserX commented Sep 12, 2026

Copy link
Copy Markdown
Owner

TestNativeDeployTarGzExecAndStop failed the macOS release build for v0.17.4 with

--- FAIL: TestNativeDeployTarGzExecAndStop (0.45s)
    native_test.go:272: captured logs missing stub output: ""

which skipped release / publish and left the tag without a release, on a commit (#135) that touched nothing in the native runtime. Re-running the identical commit passed, so it is flaky rather than a regression — but flaky here means a release silently doesn't ship.

The race. The stub writes its marker file and prints its stdout line as two separate events. The test waits for the marker, which proves the binary executed, then reads the log immediately — but the log goes through newRotatingLogWriter, which may not have flushed yet. This was the only assertion in the file that reads once; its thirteen siblings all wrap the condition in waitFor. The empty "" in the message is the tell: not wrong content, no content yet.

Reproduced, not assumed. On darwin-arm64, the same platform that failed:

result
unpatched, 40 runs, idle all pass
unpatched, under CPU contention fails in 0.43s with the exact CI message
patched, 30 runs, same contention all pass

That also explains why it only bites a loaded shared runner and never a developer machine.

I kept the 5s budget rather than inflating it, to match the other thirteen waits — a log flush is a fast event, and a log that genuinely never arrives should still fail the test. Being straight about the limit: under pathological starvation (eight CPU hogs on a laptop) the patched test can still time out at 5s. I did not chase that, because it is not a realistic runner condition and the observed CI failure was the read-once shape at 0.45s, which this removes.

Note the two other bare p.Logs reads in this file, in TestNativeLogsTailAndAbsent, are correct as they are — that test writes the log with os.WriteFile before reading and has no running process.

Summary by CodeRabbit

  • Tests
    • Improved test reliability by waiting for expected runtime output to become available before validating captured logs.

TestNativeDeployTarGzExecAndStop failed the macOS release build for v0.17.4 with
"captured logs missing stub output: \"\"" and cost the release its publish step,
on a commit that had nothing to do with the native runtime.

The stub writes its marker file and its stdout line as two separate events, so
the marker wait above proves the binary ran but says nothing about whether the
rotating log writer has flushed yet. This was the only assertion in the file that
read once instead of waiting; its thirteen siblings all use waitFor.

Reproduced locally on darwin-arm64: clean, 40 consecutive runs pass, but under
CPU contention the unpatched test fails in 0.43s with exactly the CI message.
With the wait it passes 30 runs under the same contention. Kept the 5s budget to
match the other thirteen waits — a log flush is a fast event, and a log that
genuinely never arrives should still fail.
@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: e53a7e25-f24c-438d-87b9-81df387ab882

📥 Commits

Reviewing files that changed from the base of the PR and between b9f1c69 and abe0eba.

📒 Files selected for processing (1)
  • internal/runtime/native_test.go

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The native deployment test now polls log output until the stub’s alive message appears. It retries log errors and missing output before asserting the collected logs.

Changes

Native test log capture

Layer / File(s) Summary
Poll native logs before assertion
internal/runtime/native_test.go
TestNativeDeployTarGzExecAndStop retries p.Logs through waitFor until the expected stub output is captured.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to abe0e

This improves test reliability without introducing production behavior changes or unresolved merge risk.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 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: fixing a log-flush race in a runtime test that affected macOS release builds.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/native-log-race

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.

@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.50%. Comparing base (b9f1c69) to head (abe0eba).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #136   +/-   ##
=======================================
  Coverage   78.50%   78.50%           
=======================================
  Files          18       18           
  Lines        3797     3797           
=======================================
  Hits         2981     2981           
  Misses        587      587           
  Partials      229      229           

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@GeiserX
GeiserX merged commit 2d661b1 into main Sep 13, 2026
7 checks passed
@GeiserX
GeiserX deleted the fix/native-log-race branch September 13, 2026 10:47
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