Repository navigation
fix(browser-handoff): raise handoff TTL/max-wait and retry the recheck-clear step - #214
Conversation
…k-clear step Two related fixes for the recheck reliability gap found during live retesting: - BROWSER_HANDOFF_STATE_DEFAULT_TTL_MS and MAX_TOTAL_WAIT_MS were both shorter than boon-core's async profile-snapshot step alone has been observed taking (~20 minutes), so a handoff that legitimately took a while would silently dead-end action=status into a false 'no pending handoff'/'may have expired' report instead of ever reflecting boon-core's real (ready) state. Both raised, matching Anchor's own default session max_duration (180 minutes). - scheduleRecheck gave up scheduling the next recheck forever the moment clearScheduledRecheck reported any failure, even a transient one. Since handleStatus is the only place that reschedules, one hiccup silently killed the entire recheck chain. Now retries a few times first.
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
4 issues found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="extensions/browser-handoff/src/tool.ts">
<violation number="1" location="extensions/browser-handoff/src/tool.ts:63">
P3: The new root comment embeds a lengthy live-incident narrative instead of documenting the retry invariant. Replace it with a concise explanation that transient cleanup failures are retried before abandoning the replacement schedule.</violation>
</file>
<file name="extensions/browser-handoff/src/tool.test.ts">
<violation number="1" location="extensions/browser-handoff/src/tool.test.ts:439">
P3: This test title embeds incident history instead of the invariant under test, making the suite harder to scan and maintain. Shorten it to state only that clearing the previous schedule is retried after a transient failure.
(Based on your team's feedback about concise changed source comments and test titles.)</violation>
<violation number="2" location="extensions/browser-handoff/src/tool.test.ts:455">
P3: This retry test waits on the real 200 ms backoff, which makes it slower and less deterministic under timer contention. Use fake timers, advance through the retry delay, and restore real timers in a `finally` block.
(Based on your team's feedback about deterministic retry tests.)</violation>
</file>
<file name="extensions/browser-handoff/src/state.ts">
<violation number="1" location="extensions/browser-handoff/src/state.ts:4">
P3: The new state comment is overly long and preserves incident lore in production source. Reduce it to the TTL invariant and its user-visible consequence.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
…title, use fake timers
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
…stead of hardcoding 200
There was a problem hiding this comment.
Approved. Focused reliability fix — both changes address real observed failures (60m TTL sweeping records with ready state upstream, and single transient clearScheduledRecheck failure permanently killing the recheck chain).
Good:
- TTL bump to 4h keeps
BROWSER_HANDOFF_STATE_DEFAULT_TTL_MScomfortably aboveMAX_TOTAL_WAIT_MS(180m) so the sweeper cannot beat the recheck cap — the invariant is stated in the comment. - 180m cap matches Anchor's own session
max_duration— no upside to waiting past that hard cap. - Retry loop for
clearScheduledRecheckis bounded (3 attempts, 200ms delay) and preserves the safety property (still refuses to schedule a replacement if it can't confirm the old job is cleared) — no risk of stacking overlapping rechecks. - New test uses fake timers +
finallycleanup, mock chain simulates a genuine transient failure then recovery. - Cubic's three P3 comments already addressed in later commits.
Minor observation (not blocking):
- The retry loop only backs off between attempts, not on the final failed attempt — matches your intent (
|| attempt === CLEAR_RECHECK_RETRY_ATTEMPTSshort-circuit). Total added latency worst-case is 400ms, which is fine on the request path.
Ship it.
What Problem This Solves
Live-testing the browser login handoff flow (Gmail, BuildingConnected) surfaced two related reliability gaps in the agent-side recheck loop:
BROWSER_HANDOFF_STATE_DEFAULT_TTL_MS(60 min) andMAX_TOTAL_WAIT_MS(30 min) were both shorter than boon-core's async Anchor profile-snapshot step alone has been observed taking (~20 minutes), on top of however long the human takes to sign in. Once either expired,action=statuswould silently dead-end into "no pending handoff found" or a false "may have expired" message — even when boon-core's actual backend state was alreadyready. Live-observed: the agent told a customer "Gmail's still marked not connected... the sign-in link expired" while the backend profile had a fully working, ready session.scheduleRecheckgave up scheduling the next durable recheck forever the momentclearScheduledRecheckreported any failure, even a transient one (e.g. the cron service being briefly unavailable for one call). SincehandleStatusis the only place that reschedules, one hiccup silently killed the entire recheck chain for that handoff, with nothing ever trying again.Why This Change Was Made
Both timeouts are raised to match Anchor's own default session
max_duration(180 minutes, confirmed againstdocs.anchorbrowser.io/advanced/session-timeout) rather than an arbitrary guess — waiting longer than Anchor's own hard session cap has no upside anyway. The recheck-clear step now retries a few times with a short delay before giving up, so a single transient failure no longer permanently ends the recheck chain.User Impact
Handoffs that take longer than ~30-60 minutes end-to-end (a real, observed scenario given Anchor's own snapshot latency) no longer get falsely reported as expired/not-connected once the fix in boon-core (companion PR) makes the snapshot step itself much faster in the common case. The recheck loop is also more resilient to one-off scheduling hiccups.
Evidence
node scripts/run-oxlint.mjsandoxfmt --checkclean on touched files.ready).Summary by cubic
Fixes two reliability gaps in the browser handoff recheck loop that caused false "expired"/"not connected" reports and silently dead handoffs.
Bug Fixes
Links to ENG-17466 for the browser login handoff reliability work.
Written for commit 90ad1d6. Summary will update on new commits.