Skip to content

fix(client): preserve cursor on reconnect exhaustion - #619

Open
iroiro147 wants to merge 1 commit into
vercel:mainfrom
iroiro147:fix/client-reconnect-exhaustion-134
Open

fix(client): preserve cursor on reconnect exhaustion#619
iroiro147 wants to merge 1 commit into
vercel:mainfrom
iroiro147:fix/client-reconnect-exhaustion-134

Conversation

@iroiro147

Copy link
Copy Markdown
Contributor

Description

Fixes #134.

When a message stream ends before the current turn reaches session.waiting, session.completed, or session.failed and the reconnect budget is exhausted, ClientSession now preserves the resumable cursor and throws StreamReconnectExhaustedError instead of resetting to a fresh session state.

This also keeps EveAgentStore in error for that path, so frontend bindings do not report ready and the next ordinary send does not silently start a new conversation. Manual session.stream() reattaches from the preserved cursor; an empty reattach leaves the cursor unchanged.

This PR also adds client/API/store regression coverage, docs for the catch-and-persist pattern, and a patch changeset.

How did you test your changes?

  • node -v (v24.14.0)
  • git diff --cached --check
  • pnpm --filter eve exec vitest run --config vitest.unit.config.ts src/client/session.test.ts src/vue/use-eve-agent.test.ts test/client.test.ts (52 passed)
  • pnpm --filter eve exec vitest run --config vitest.unit.config.ts src/client test/client.test.ts src/react/use-eve-agent.test.ts src/vue/use-eve-agent.test.ts src/svelte/use-eve-agent.test.ts (96 passed)
  • pnpm --filter eve run typecheck
  • pnpm --filter eve exec oxlint src/client/session.ts src/client/session-utils.ts src/client/session-errors.ts src/client/session.test.ts src/vue/use-eve-agent.test.ts test/client.test.ts --deny-warnings
  • pnpm exec oxfmt --check packages/eve/src/client/session.ts packages/eve/src/client/session-utils.ts packages/eve/src/client/session-errors.ts packages/eve/src/client/index.ts packages/eve/src/client/session.test.ts packages/eve/src/vue/use-eve-agent.test.ts packages/eve/test/client.test.ts docs/guides/client/streaming.mdx docs/guides/frontend/overview.mdx .changeset/client-reconnect-exhaustion.md
  • pnpm docs:check
  • pnpm guard:invariants
  • pnpm changeset status --since origin/main

PR Checklist

  • I linked an issue with prior discussion confirming this change is wanted
  • I ran the relevant checks from CONTRIBUTING.md
  • I added tests and documentation where relevant
  • I added a changeset if this touches the published eve package
  • DCO sign-off passes for every commit (git commit --signoff)

@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

@iroiro147 is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@iroiro147
iroiro147 force-pushed the fix/client-reconnect-exhaustion-134 branch from b5b2ed5 to e251b7b Compare July 12, 2026 12:28
@iroiro147

Copy link
Copy Markdown
Contributor Author

Rebased this onto current main and pushed signed head e251b7bb. I also hardened the reconnect path so a failed reopen preserves the consumed cursor, clean manual-stream EOF returns normally, and only classified socket disconnect exhaustion raises StreamReconnectExhaustedError. Added regressions for all three cases. Verified under Node 24 with 43 focused tests, package typecheck, invariant checks, and git diff --check; fresh CI is running.

Signed-off-by: iroiro147 <sarthak.singh@juspay.in>
@iroiro147
iroiro147 force-pushed the fix/client-reconnect-exhaustion-134 branch from e251b7b to eceb150 Compare July 30, 2026 06:17
@iroiro147

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main (eceb150). Resolved 5 file conflicts:

  • session.ts, open-stream.ts, session-utils.ts: took PR version — main evolved the streaming/reconnect logic (followStreamIterable, idleRetryPolicy, summarizeTurnEvents) in a different direction from the PR's approach (openStreamIterable, StreamReconnectExhaustedError, preserveActiveSession). The PR's implementation is self-consistent.
  • session.test.ts: merged — kept main's test options (preserveCompletedSessions, redirect, resolveHeaders) + PR's maxReconnectAttempts option.
  • docs/guides/frontend/overview.mdx: kept both — main's optimistic option docs + PR's maxReconnectAttempts option docs.

@iroiro147

Copy link
Copy Markdown
Contributor Author

Attempted rebase onto current main — blocked on two semantic conflicts in packages/eve/src/client/session.ts (lines ~219-231 and ~337-346).

Upstream landed two feature PRs that rewrote the exact stream-read loops this change touches: #1239 (stable event ids) and #1219 (bounded catch-up reads at the durable tail), a net +265/−145 refactor of this file. The cursor-preservation logic here needs to be recomposed against the new stable-id / bounded-catch-up model — a mechanical merge would compile but silently change reconnect semantics.

Rather than guess at the intended composition, flagging for author: how should the reconnect-exhaustion cursor carry over the new streamIndex/startIndex and the bounded-catch-up read? Happy to rebase once the intended seam is confirmed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stream reconnect exhaustion silently clears the session while the durable turn continues

1 participant