fix(service): report the wait that was actually spent, not the budget - #3138
fix(service): report the wait that was actually spent, not the budget#3138ntdatt812 wants to merge 1 commit into
Conversation
Follow-up to lidge-jun#3134, which named this as the one piece of lidge-jun#3039 it deliberately did not carry. reportServiceServing printed Math.trunc(healthBudgetMs / 1000) — the budget it allowed — while confirmServiceServing knocks once more after a 500ms grace sleep whenever it waited at all. So a Windows run that gives up reports "within 45s" after spending 45.5s. The gap is half a second today. It is the expression that is wrong, not the number: it states a figure the run did not spend, and it understates every future grace the loop grows. The reader is using it to judge whether the service was merely still coming up, which is a question about elapsed time. The wait is now timed in reportServiceServing, through the same injected `now` the deps already carry, so confirmServiceServing's contract and its existing tests are untouched. Two tests: - the Windows budget case asserts the clock reached 45_000 + 500 and that the line says "after 46s" — the rounded real wait — and no longer says 45s; - a zero budget takes the single probe, skips the grace, and reports "after 0s", so a caller that asked not to wait is not told it waited. Reverting to the budget expression fails both. tests/service.test.ts: 183 pass, 6 fail. Those six fail identically on a clean `dev` checkout on this host (Windows) and are untouched by this change; compared by test name rather than by count.
|
✅ Deterministic PR hygiene checks passed. |
✅ READY
Review readiness checklist
✅ 4/4 boxes ticked. This pull request is already Ready for Review. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthrough
ChangesService wait reporting
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized change corrects the reported service-wait duration without changing health checks, connectivity, permissions, deployment behavior, or persisted state. No actionable merge-blocking risk remains at the current head beyond normal checks and review. 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 |
Ingwannu
left a comment
There was a problem hiding this comment.
Reviewed exact head dda9e80. The two-file production/test change is correct and narrowly scoped: reportServiceServing measures the same injected clock around confirmServiceServing, clamps backward-clock results at zero, reports the real elapsed wait, and keeps the zero-budget single-probe path honest. The focused regressions cover both the 45.5s Windows path and zero wait. I found no source-code blocker in this patch.
Final approval is blocked only by exact-head CI and base drift. Linux shard 3/4 failed at tests/server-auth.test.ts:2289 on the unrelated websocket-refresh fixture. This branch is four commits behind current dev, which now contains #3139 (c8c8dc338) specifically fixing that startup-prime race. Please rebase this unchanged service patch onto current dev and rerun the complete exact-head matrix. If the range-diff remains equivalent and CI is green, this is an approval candidate; no additional service behavior change is requested.
|
The red on this PR is
The same test fails on Two notes in case they save someone time, one of them a correction: The diff is a substitution, not an extra element. GitHub redacts the tokens #3139 does not appear to have closed it. That commit moved I could not reproduce it locally (Windows, bun 1.3.14): the test passes on One thing worth checking if you are still on it: the fixture stamps Happy to rebase this PR once |
리뷰 · 우선순위 52 / 80설명 이 PR은 #3134가 의도적으로 남긴 #3039 조각을 닫습니다. 지금 HEAD 파일은 점수는 52입니다. 관측 가능성 수정이고 기능/보안 구멍은 아닙니다. #3158이 언급한 launcher 플래크와도 직접 같지는 않습니다(그쪽은 start 거절/#3144 축). 라인 src/service.ts 메인테이너의 판단이 필요한 지점
너의 추천 이 댓글은 grok-bot이 작성했습니다 |
Follow-up to #3134, which named this as the one piece of #3039 it deliberately did not carry, and said it deserved its own resolution. This is that.
The gap
reportServiceServingprints the budget it allowed:while
confirmServiceServingknocks once more after a 500ms grace sleep whenever it waited at all:So a Windows run that gives up spends 45.5s and reports
within 45s.Half a second is not the point. The expression is wrong rather than the number: it states a figure the run did not spend, and it understates every future grace the loop grows. What the reader is deciding is whether the service was merely still coming up — which is a question about elapsed time, and #3009 is the report of exactly that misjudgement being made.
The change
The wait is timed in
reportServiceServing, through the same injectednowthe deps already carry:confirmServiceServing's return shape and contract are untouched, so its existing tests — including the zero-budget single-probe assertion #3104 was right to restore — are untouched too. Nine lines, one file.Math.roundrather thanMath.trunc: truncating 45.5s back to 45 would reintroduce the understatement this fixes.Tests
reports the wait it actually spent, grace knock includedSERVICE_INSTALL_HEALTH_WINDOWS_MS + 500, the line saysafter 46s, and no longer says45sreports no wait when the caller asked not to waitafter 0sThe second one exists because "report the elapsed time" has an obvious wrong version — reporting the budget when nothing was waited — and the zero-budget path is where that shows.
Reverting to the budget expression fails both.
Verification
Those six fail identically on a clean
devcheckout on this host (Windows) —service listen-port bake×2,service install auth preflight×2,service lifecycle cleanup ordering×2. Compared by test name rather than by count, and none is touched by this diff.Thank you for splitting this out instead of closing #3039 over it.
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
All CI tests are green on my local testing.
I pushed my PR to the latest dev commit.
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Summary by CodeRabbit