Skip to content

test(account): check P22's expiry from the replacement's own stamp - #4386

Merged
devswha merged 1 commit into
mainfrom
test/link-replacement-clock
Nov 20, 2026
Merged

devswha merged 1 commit into
mainfrom
test/link-replacement-clock

Conversation

@devswha

@devswha devswha commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Summary

server/account/link-replacement.test.ts (P22) read Date.now() before linkAccountKey, which stamps the replacement with its own Date.now(). When the clock moved a millisecond between the two, now + FIVE_MINUTES + 1 was still inside the five minutes and the replacement was confirmed, so the test failed now and then (seen in a check fast run on hosthatch while checking #4384; it passed 6/6 locally). The test now takes the time the replacement was stamped with from pendingReplacement and checks one millisecond past its five minutes. No product change.

Validation

  • With a preload that moves Date.now() 5 ms per call: before, P22 fails; after, it passes.
  • bun test server/account/link-replacement.test.ts: 10 pass, 3 runs.
  • bun run check fast (remote, hosthatch): exit 0 before this push.
  • Test-only: no CodeRabbit review needed (AGENTS.md); omo review only.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Updated the replacement-link expiry test to check the timeout relative to the recorded link time.

The link replacement expiry test now uses the replacement’s recorded timestamp to check confirmation just beyond five minutes.

Changes: Link replacement expiry test

Layer / File(s) Summary
Expiry boundary check
server/account/link-replacement.test.ts
The test reads the replacement timestamp after linking and checks that confirmation at five minutes and one millisecond later returns null.

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

Change: Other

Merge Risk: Minimal · up to 9ec0c

This is a test-only change that removes an intermittent timing flake in the link replacement expiry test. It has no product impact and is ready to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the changed test (P22) and the core change: measuring expiry from the replacement's own stored timestamp. It is specific and matches the summary and objectives.
Description check Passed The description states the problem (Date.now() read before linkAccountKey causing a flaky clock-tick race), the fix (use pendingReplacement timestamp, check +1 ms past five minutes), and validation (p…
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 states the problem (Date.now() read before linkAccountKey causing a flaky clock-tick race), the fix (use pendingReplacement timestamp, check +1 ms past five minutes), and validation (preload test before/after, 3 runs of the test file, check fast). It covers the template's Change and Validation sections. It does not link an issue, but this is a test-only fix and the template only requires a link for features. Contract-test coverage is not mentioned, which is not needed for a test-only change.

Finishing Touches

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 5c190e7 and 9ec0c06.

Files selected for processing: 1

  • server/account/link-replacement.test.ts

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

@devswha
devswha merged commit 059ff50 into main Nov 20, 2026
23 checks passed
@devswha

devswha commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

Merged through pr-merge at head 9ec0c0667. Seen before the merge was asked for: required checks green, no unresolved thread, no conflict, no hold, main not red, no release in progress. CodeRabbit reviewed this head.

Test-only fix of a clock race in P22 (no product change). Reviews: dori review (omo) CLEAR at 9ec0c06 and CodeRabbit reviewed this head; test-only PRs need omo alone (OVIS-RULES). Proven with a preload that ticks Date.now 5 ms per call: before fails, after passes. check fast exit 0 on hosthatch.

@devswha
devswha deleted the test/link-replacement-clock branch November 20, 2026 23:22
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