test(lib): make idle deadline reset timing deterministic - #4041
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughChangesIdle deadline test validation
Priority: ⬇️ Low — Defer this test-only change because it is limited to deterministic idle-deadline timing coverage with no runtime behavior changes. Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: 🟡 Moderate · up to The timer-test rewrite does not change runtime behavior, but a reported duplicate declaration may prevent the test file from compiling. Confirming a clean typecheck is needed before merge. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
✅ Deterministic PR hygiene checks passed. |
✅ READY
Review readiness checklist
✅ 4/4 boxes ticked. This pull request has been marked Ready for Review. Hygiene✅ Deterministic PR hygiene checks passed. |
|
@coderabbitai review Please review head Only the reset/postpone test changes behavior; runtime code and five real-timer tests stay unchanged. The virtual fixture models scheduling/cancellation only, runs without await while global spies are installed, and restores those individual spies in nested finally blocks. Six tests / twelve assertions pass. Controlled late resumption reproduces the old assertion failure, and isolated mutations removing cancellation or disabling repeated reset both fail the new test; the real-timer pause/rearm control still passes after each failed assertion, exercising cleanup. Typecheck, privacy scan, diff check, and independent review passed. Full contributor CI is separate and pending. |
🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
base='7dc7dc99e65268bc8764e19840952256b030bce9'
head='9aa3e9204c12c1bbd9068e77115501e16203bb60'
echo '=== Changed files and diff ==='
git diff --stat "$base" "$head"
git diff --check "$base" "$head"
git diff --find-renames --unified=100 "$base" "$head" -- tests/lib/abort-idle-deadline.test.ts
echo '=== Changed test outline ==='
ast-grep outline tests/lib/abort-idle-deadline.test.ts --items all || true
echo '=== Changed test, numbered ==='
nl -ba tests/lib/abort-idle-deadline.test.ts
echo '=== idleDeadline definitions and references ==='
rg -n -C 5 --glob '!tests/lib/abort-idle-deadline.test.ts' \
'\bidleDeadline\b|function\s+idleDeadline|const\s+idleDeadline|export.*idleDeadline' .
echo '=== Timer API declarations and imports in relevant source candidates ==='
rg -n -C 4 --glob '*.{ts,tsx,js,mjs,cjs}' \
'\b(setTimeout|clearTimeout|setInterval|clearInterval)\b' \
src lib packages tests 2>/dev/null || trueLength of output: 6116 🏁 Script executed: #!/bin/bash
set -euo pipefail
head='9aa3e9204c12c1bbd9068e77115501e16203bb60'
echo '=== Numbered changed test at reviewed head ==='
git show "${head}:tests/lib/abort-idle-deadline.test.ts" | awk '{ printf "%6d %s\n", NR, $0 }'
echo '=== Locate abort implementation candidates at reviewed head ==='
git ls-tree -r --name-only "$head" | grep -E '(^|/)(abort|abort\.(ts|tsx|js|mjs|cjs))$|/abort\.(ts|tsx|js|mjs|cjs)$' || true
echo '=== Production implementation: src/lib/abort.ts ==='
git show "${head}:src/lib/abort.ts" | awk '{ printf "%6d %s\n", NR, $0 }'
echo '=== Timer API and idleDeadline context in tracked source ==='
git grep -n -E '\bidleDeadline\b|\b(setTimeout|clearTimeout)\b' "$head" -- 'src/**' \
| head -n 300 || true
echo '=== Parent test version for direct comparison ==='
git show '7dc7dc99e65268bc8764e19840952256b030bce9:tests/lib/abort-idle-deadline.test.ts' \
| awk '{ printf "%6d %s\n", NR, $0 }'Length of output: 53673
The synchronous fixture preserves the meaningful reset/deadline coverage:
The test directly detects both key regressions: failure to cancel the old handle before re-arming, and failure to re-arm when a pending timer exists. The remaining five cases still use real timers. ✅ Action performedReview finished.
|
리뷰 · 우선순위 63 / 80이 PR은 런타임 코드가 아니라 테스트만 고친다. 대상은 문제는 테스트가 “40ms씩 네 번 자고 매번 reset하면, 전체는 160ms를 넘어도 한 번도 안 터져야 한다”고 가정한 점이다. 스케줄러가 밀리면 실제 이 PR은 그 경계 케이스만 지금 라인 쪽: 메인테이너의 판단이 필요한 지점
너의 추천 이 댓글은 grok-bot이 작성했습니다 |
* test(lib): make idle deadline reset timing deterministic Carried from #4041 (author luvs01) for maintainer-side CI and sequential integration. Co-authored-by: luvs01 <27862058+luvs01@users.noreply.github.com> * test: stabilize Windows fixture waits and case cleanup Carried from #4015 (author luvs01) for maintainer-side CI and sequential integration. Co-authored-by: luvs01 <27862058+luvs01@users.noreply.github.com> * test(codex): verify timeout termination without racing child timers Carried from #4012 (author luvs01) for maintainer-side CI and sequential integration. Co-authored-by: luvs01 <27862058+luvs01@users.noreply.github.com> * test(codex): hold prompt-probe admission through document edits Carried from #4014 (author luvs01) for maintainer-side CI and sequential integration. Co-authored-by: luvs01 <27862058+luvs01@users.noreply.github.com> * test(clients): bound transaction fixture child completion Carried from #4004 (author luvs01) for maintainer-side CI and sequential integration. Closes #4003 Co-authored-by: luvs01 <27862058+luvs01@users.noreply.github.com> * fix(codex): retain overlapping multiline TOML terminators Carried from #4039 (author luvs01) for maintainer-side CI and sequential integration. Co-authored-by: luvs01 <27862058+luvs01@users.noreply.github.com> * fix(cli): reject unsupported caps and report ignored legacy values Carried from #4043 (author luvs01) for maintainer-side CI and sequential integration. Co-authored-by: luvs01 <27862058+luvs01@users.noreply.github.com> * fix(codex): share trigger-only delegation guidance with v1 Carried from #4034 (author luvs01) for maintainer-side CI and sequential integration. Co-authored-by: luvs01 <27862058+luvs01@users.noreply.github.com> * fix(codex): preserve settings when journal injection hashes are missing Carried from #4006 (author luvs01) for maintainer-side CI and sequential integration. Closes #4005 Co-authored-by: luvs01 <27862058+luvs01@users.noreply.github.com> * docs(cli): note that --injection still accepts none and minimal CodeRabbit review on #4049: the effort reference documents caps only, so the new rejection of none/minimal reads as a global removal. --injection keeps both values because it sets the injection effort rather than a cap. --------- Co-authored-by: t <a@b.com> Co-authored-by: luvs01 <27862058+luvs01@users.noreply.github.com>
|
Landed on Verification at the exact merged head Closing this PR because the change is already on |
Summary
The
idleDeadlinereset/postpone test assumes each requested 40 ms sleep resumes before a 120 ms idle deadline. Under scheduling delay, the production timer can correctly fire before the next reset, making the test fail even though the primitive's contract is satisfied. This occurred in the macOS control for #4036: the test reported 432.21 ms and observed one firing where it expected zero. The primitive and this test were unchanged by that PR; individual callback timings were not logged, so the exact delayed interval is unknown.Make only this boundary case synchronous with a scoped timer fixture. The fixture models generic timer scheduling/cancellation, while the real
idleDeadlineimplementation handles resets and terminal state. Advance 40 ms and reset four times, verify no firing through another 119 ms, then verify exactly one firing at the next millisecond and no later repeat. Individual spies are restored in nestedfinallyblocks. The five other cases still exercise Bun's real timers. Runtime code and user behavior are unchanged, so no documentation update is needed.Verification
9aa3e9204c12c1bbd9068e77115501e16203bb60, based ondev7dc7dc99e65268bc8764e19840952256b030bce9; Bun 1.4.0 on Windows. Onlytests/lib/abort-idle-deadline.test.tschanges.bun run test -- --timeout 60000 --parallel=1 tests/lib/abort-idle-deadline.test.ts: 6 tests / 12 assertions passed, 678 ms, including all five unchanged real-timer cases. Cases following the modified test run after spy restoration.bun run typecheck,bun run privacy:scan, andgit diff --checkpassed. Independent read-only review found no required corrections in mock lifetime, timer handles, or assertion coverage.9aa3e9204, including all Windows shards and the macOS control. Currentdevremains7dc7dc99e.Checklist
Review readiness checklist