fix(sdk): reconnect protocol SSE after clean EOF - #2708
fix(sdk): reconnect protocol SSE after clean EOF#2708Daniel Peng (original4422) wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: f74e3d2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
This PR fixes a LangGraphJS SDK transport bug where a thread-centric SSE subscription handle could remain “active” while the underlying SSE response ended cleanly, preventing subsequent events from being delivered and bypassing the existing reconnect/backoff logic.
Changes:
- Treats clean SSE EOF as an unexpected disconnect (unless explicitly aborted/closed) so it flows through the existing reconnect path.
- Adds targeted transport-level tests covering clean-EOF reconnect, zero retry budget behavior, and explicit close behavior.
- Publishes a patch changeset describing the reconnect-after-EOF fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| libs/sdk/src/client/stream/transport/http.ts | Routes clean SSE EOF through the reconnect/error path rather than silently closing the shared queue. |
| libs/sdk/src/client/stream/transport/http.test.ts | Adds focused tests for clean-EOF reconnect behavior, retry-budget exhaustion, and explicit close behavior. |
| .changeset/steady-streams-reconnect.md | Declares a patch release note for reconnecting SSE streams after clean EOF. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
@langchain/langgraph-checkpoint
@langchain/langgraph-checkpoint-mongodb
@langchain/langgraph-checkpoint-postgres
@langchain/langgraph-checkpoint-redis
@langchain/langgraph-checkpoint-sqlite
@langchain/langgraph-checkpoint-validation
create-langgraph
@langchain/langgraph-api
@langchain/langgraph-cli
@langchain/langgraph
@langchain/langgraph-cua
@langchain/langgraph-supervisor
@langchain/langgraph-swarm
@langchain/langgraph-ui
@langchain/langgraph-sdk
@langchain/angular
@langchain/react
@langchain/svelte
@langchain/vue
commit: |
Summary
Root cause
ProtocolSseTransportAdapter.openEventStream()only reached its reconnect logic when stream consumption threw. A successful SSE response that ended normally closed the shared queue and returned, leaving the retained thread stream handle unable to observe later events.The fix keeps explicit abort/shutdown terminal, but turns an otherwise clean EOF into the same existing unexpected-disconnect path. It does not introduce a second retry loop or change replay cursor behavior. PR #2689 modifies adjacent durable cursor handling and should compose with this narrow EOF-boundary change.
Test plan
pnpm exec vitest run src/client/stream/transport/http.test.ts --reporter=verbose(fromlibs/sdk): 20 passed, no type errorspnpm --filter @langchain/langgraph-sdk test: 53 files / 778 tests passed, no type errorspnpm format:check: passed (440 files)pnpm lint: passed (1,162 files, 0 warnings/errors)pnpm --filter @langchain/langgraph-sdk build: passed, including attw and publintpnpm build: 25/25 tasks passedFixes #2701