Skip to content

[build-tools] Keep the sandbox wall-time test stable when other code reads the clock - #4751

Closed
gwdp wants to merge 1 commit into
mainfrom
gwdp/sandbox-wall-time-test-clock
Closed

gwdp wants to merge 1 commit into
mainfrom
gwdp/sandbox-wall-time-test-clock

Conversation

@gwdp

@gwdp gwdp commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Why

sandboxDaemonCommands.test.ts › measures each call separately failed once in CI run 40253762840 with Received 72.751534592 instead of 0.25. The test mocks the shared process clock with a queue of two values. Any other code that reads performance.now() during the call, such as Node's built-in fetch, takes one of the values, so the end read gets the real clock: (73,751 − 1,000) / 1,000 = 72.75.

How

  • The mocked clock is now a stable value. Other code that reads it does not change it.
  • The clock moves only when the measured shell read finishes, by 250 ms for the first call and 100 ms for the second, so each call still reports only its own read time.

Test Plan

Claude Code ran these checks on d6651d6: lint, format check and typecheck pass.

  • The old test fails when one fetch runs during the call. The new test passes.
  • The whole test file passes in repeated runs.
Repro counts (Node 22.23.4)
  • Natural failures on main: 0 of 48 runs (20 single-test runs, 25 file runs with coverage under CPU load, 3 full build-tools runs with 3 workers).
  • One fetch during the call: main fails 3 of 3; this change fails 0 of 3.
  • Whole file with this change: 20 of 20 runs pass, 32 tests each.

Authorship and LLM use

  • LLM involvement: primarily LLM-generated. Claude Code wrote the code, tests and this description.
  • Process: Gabe asked for the root cause of the CI failure, not a rerun.
  • History: an AI review approved the change. The forced repro failed on the old test before the fix.
  • Human involvement: Gabe set the direction.
  • Review status: human review pending; Gabe can answer questions.

Rollback

Revert this PR; only the test changes.

Generated with T3 Code, using Claude Code.

…ock readers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gwdp

gwdp commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

/devin review

@devin-ai-integration

Copy link
Copy Markdown

Starting Devin Review.

Devin Review

@github-actions

Copy link
Copy Markdown

✅ Thank you for adding a changeset!

@devin-ai-integration devin-ai-integration 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.55%. Comparing base (d02de4d) to head (d6651d6).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4751   +/-   ##
=======================================
  Coverage   75.55%   75.55%           
=======================================
  Files        1053     1053           
  Lines       52399    52399           
  Branches    11442    11442           
=======================================
  Hits        39587    39587           
  Misses      11831    11831           
  Partials      981      981           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

@gwdp gwdp closed this Oct 26, 2026
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