Repository navigation
test(agents): the listener check-in test waits for the write, not a fixed 150 ms - #3452
Conversation
…ixed 150 ms The check-in write is fire-and-forget, and the test slept 150 ms before reading the route. In the merge queue on 11-04 that lost the race in two of five runs (the file's first test, while a new AgentEvent index built), dequeuing unrelated PRs. It now waits until the stamp is in the database, up to 5 s, then reads the route once. Polling the route itself trips its rate limit (429). A check-in that never writes still fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MDs9DPFVAooJnqCSwrdxVw
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
lilyshen0722
left a comment
There was a problem hiding this comment.
HEAD: d9b1acf — GATE: PASS
One quick review round (Tier 0, test only).
- The wait proves what the route reads.
/agent-states→deriveAgentState→latestListenreadslastListenedAtstraight from Mongo onAgentInstallation.runtimeTokensand on the bot User'sagentRuntimeTokens, with no cache in between. Test 1 waits on the User field, which is the only source there, because its installation has no tokens. Test 2 waits on the installation field.$ne: nullexcludes both a missing field and a null one. - The filters are specific. Each test filters on a name only it uses (
mcp-only,install-only), and neither row can match the other's filter. - A write that never lands still fails.
landedreturns after 5 s, then the route assertion fails withnever-connected. That's under the 30 s testTimeout. The PR's reverse check confirms it. - Flake risk is low. There's a single route read, so no rate limit; the throttle resets
beforeEach; and each update is atomic.
GATE: PASS
Why
agent-states-listener-check-in.test.js› "an MCP call alone is never-connected; a check-in on the User token flips it to listening" failed in two of the last five merge-queue runs on 11-04 (runs 41922149243 and 41923958639) withExpected: "listening" / Received: "never-connected", and dequeued unrelated PRs (#3446 twice).The check-in write is fire-and-forget, and the test slept a fixed 150 ms before reading the route. That race is lost under queue load: it's the file's first test, running while #3443's new AgentEvent index builds. It is not a regression: it passes 3 of 3 on main locally, and main's push-run Backend tests are green, per SRE.
Change (test only)
The test now waits until the
lastListenedAtstamp is in the database (Model.exists, polled every 25 ms, for up to 5 s), then reads the route once. Polling the route itself was tried first: it trips the route's rate limit (429).Proof
recordListenerCheckIncalls removed, both tests still fail (Received: "never-connected"), so the wait can't hide a check-in that never writes.🤖 Generated with Claude Code
https://claude.ai/code/session_01MDs9DPFVAooJnqCSwrdxVw