Repository navigation
fix(messaging): report an expired deadline as operation_timeout when a stage timer fires first - #8850
Conversation
…a stage timer fires first A connect or request timer capped by the remaining operation budget could run before the budget's own timer on a loaded event loop, relabelling a deadline expiry as rpc_timeout or daemon_unavailable. MessageBudget.stageTimer now ends the operation through the budget when the timer was capped by, or fires at or after, the deadline. Fixes the lane=all run 43912748460 "test 5/5" flake in messaging-local-lifecycle.test.ts.
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. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
✅ Deterministic PR hygiene checks passed. |
Summary
Fixes a dev-red flake from the
lane=allrun 43912748460, job test 5/5 (self-hosted Linux, dev1d5c5c1c2b):Cause.
MessageBudgetarms one timer for the whole operation deadline (operation_timeout).LocalMessageRpcarms a second timer per request (rpc_timeout) and for connect (daemon_unavailable), usingbudget.remainingMs(limit). When the remaining budget is shorter than the RPC limit, both timers end at about the same moment. On a loaded runner the stage timer can run first, so an expired deadline was reported as an RPC timeout or a connection timeout.Change.
MessageBudget.stageTimer(limit, onStageTimeout)arms the stage timer. If the deadline capped the timer, or the timer fires at or after the deadline, it ends the operation through the budget's existing abort path (operation_timeout, same message). Otherwise it calls the stage's own timeout. Bothrpc.tstimers (connect and request) use it. A real per-request timeout shorter than the remaining budget still reportsrpc_timeout.structure/local-messaging.mdrecords the rule.Verification
All test runs were single files under
/usr/bin/lockf -k /tmp/ocx-test.lock.tests/codex-integration/messaging-local-lifecycle.test.ts. They replacesetTimeout/clearTimeoutandperformance.nowwith hand-driven versions, move the clock to the deadline, and fire the connect timer or the request timer before the budget's own timer. A third case pins a 100 ms RPC limit against a 30 s budget torpc_timeout. The existingtoThrow("deadline")assertion is unchanged.origin/devsource (5b864ad4c8):11 pass / 2 fail. The connect case receivedLocal Codex connection timed out; no daemon was started.The request case receivedLocal Codex request timed out., the same message as in CI.13 pass / 0 fail.src/messagingor the messaging helpers (27 files), run one at a time. 25 passed, two of them with expected platform skips. Two remote files hit their 5 s per-test timeout while the host load average was about 32 to 34:messaging-remote-replies.test.ts("reply routes have fixed capacity…") times out the same way withsrc/messagingstashed back toorigin/dev, so this change did not cause it.messaging-remote-admission.test.ts("outbound enrollment permits one correlated return reply…") timed out twice with the fix, then passed on rerun (4647 ms against its 5000 ms limit). Its success path never fires a connect or request timer, so it is sensitive to load.bun run typecheck: no type errors.bun run structure:check: passed.bun run privacy:scan: passed.NOT RUN: full
bun run test(shared host, excluded by the task); macOS/Windows CI.Follow-up outside this PR:
src/messaging/remote-auth.ts:28uses the same cappedsetTimeout(fail, budget.remainingMs(5000))shape and could adoptstageTimerin a later change.Checklist
Summary by CodeRabbit