Skip to content

fix(sdk): reconnect protocol SSE after clean EOF - #2708

Open
Daniel Peng (original4422) wants to merge 2 commits into
langchain-ai:mainfrom
original4422:fix/sse-clean-eof-reconnect
Open

fix(sdk): reconnect protocol SSE after clean EOF#2708
Daniel Peng (original4422) wants to merge 2 commits into
langchain-ai:mainfrom
original4422:fix/sse-clean-eof-reconnect

Conversation

@original4422

Copy link
Copy Markdown

Summary

  • treat clean SSE EOF as an unexpected disconnect while the event-stream handle remains active
  • route it through the existing reconnect callback, retry budget, and backoff path
  • preserve terminal behavior for explicit handle or transport close
  • add focused coverage for event delivery across reconnect, zero retry budget, and explicit close

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 (from libs/sdk): 20 passed, no type errors
  • pnpm --filter @langchain/langgraph-sdk test: 53 files / 778 tests passed, no type errors
  • pnpm format:check: passed (440 files)
  • pnpm lint: passed (1,162 files, 0 warnings/errors)
  • pnpm --filter @langchain/langgraph-sdk build: passed, including attw and publint
  • pnpm build: 25/25 tasks passed

Fixes #2701

Copilot AI lite review requested due to automatic review settings August 19, 2026 20:11
@changeset-bot

changeset-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f74e3d2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@langchain/langgraph-sdk Patch
@langchain/angular Patch
@langchain/react Patch
@langchain/svelte Patch
@langchain/vue Patch

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread libs/sdk/src/client/stream/transport/http.test.ts Outdated
@pkg-pr-new

pkg-pr-new Bot commented Aug 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

@langchain/langgraph-checkpoint

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint@2708

@langchain/langgraph-checkpoint-mongodb

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint-mongodb@2708

@langchain/langgraph-checkpoint-postgres

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint-postgres@2708

@langchain/langgraph-checkpoint-redis

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint-redis@2708

@langchain/langgraph-checkpoint-sqlite

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint-sqlite@2708

@langchain/langgraph-checkpoint-validation

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint-validation@2708

create-langgraph

npm i https://pkg.pr.new/langchain-ai/langgraphjs/create-langgraph@2708

@langchain/langgraph-api

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-api@2708

@langchain/langgraph-cli

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-cli@2708

@langchain/langgraph

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph@2708

@langchain/langgraph-cua

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-cua@2708

@langchain/langgraph-supervisor

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-supervisor@2708

@langchain/langgraph-swarm

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-swarm@2708

@langchain/langgraph-ui

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-ui@2708

@langchain/langgraph-sdk

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-sdk@2708

@langchain/angular

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/angular@2708

@langchain/react

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/react@2708

@langchain/svelte

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/svelte@2708

@langchain/vue

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/vue@2708

commit: f74e3d2

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.

[SDK] Thread-centric SSE stream does not reconnect after clean EOF

2 participants