Repository navigation
fix(lib): read the clock under the lock in cli-version-check claimDaily - #18075
kyle-sexton wants to merge 2 commits into
Conversation
claimDaily took `now` from a default parameter, before the lock. A claimant that read the clock, then took the lock only after another claimant had stamped a later time, saw that stamp as a future one and claimed again, so two of 24 concurrent claims won on CI (main run 44950479481, attempt 1). The clock is now read inside the lock, and checkVersion no longer captures it early either. A regression test lands a claim between the clock read and the lock and expects the late claimant to lose. Closes #18063 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
claude-review reviewed Code review: PR #18075,
|
|
claude-security-review reviewed Security review: no security issues foundThis change fixes a race in What I checked:
The three plugin copies have the same change as critical-findings: 0 |
|
The pr-verify verifier failed head This pull request leaves the merge queue, and ci-status holds it out while it carries |
Closes #18063
Summary
lib/cli-version-check.test.shfailed on main in run 44950479481, attempt 1, job "Test Bash (6)". The suite did not stop after test 2. TheFAIL:line printed after test 2 is the runner's summary line, interleaved with the streamed output. The job's failure block names the test:✖ only one of many processes claiming the same name at once wins,AssertionError: 2 !== 1atlib/cli-version-check.test.mjs:134. Two of 24 concurrentclaimprocesses won.Cause:
claimDailyread the clock in a default parameter (now = Date.now()), before it took the lock. The race goes like this:now.last <= nowfails) makes the job due, so the first claimant wins as well.checkVersionhad the same early read, with a wider window.Fix
claimDailyreads the clock inside the lock when nonowis passed. Claims are stamped in lock order, so a later lock holder can no longer see an earlier holder's stamp as a future one.checkVersionno longer defaultsnowitself; it passes it through.mkdirSync, which runs between the two) and expects the late claimant to lose.Verification
actual: { inner: true, outer: true }, expectedouter: false. This is the same two-winner result CI saw.only one of many processes claiming…), pinned to 2 CPUs with 4 busy loops at default priority and the test atnice 19:2 !== 1. These counts match the fix but are small. The deterministic test above is the evidence that settles the cause.scripts/sync-shared-copies.sh --check-bump origin/mainpasses.scripts/check-affected.shreports 17 passed and 3 skipped.lib/prerequisites.test.mjs, which callscheckVersion, has the same 10 local failures (of 370) on this branch and on main. They come from the tools installed on this machine.Related
exclusively()inlib/cli-version-check.mjscan delete a fresh lock when the lock vanishes betweenEEXISTandstat(it then readsmtimeMs ?? 0as stale). It is not this failure's cause; a follow-up handles it.🤖 Generated with Claude Code