Skip to content

fix(sdk): prevent stale client closure in useStream hook#1895

Open
sivashankar0398-cmyk wants to merge 1 commit intolangchain-ai:mainfrom
sivashankar0398-cmyk:fix-stale-client-hook
Open

fix(sdk): prevent stale client closure in useStream hook#1895
sivashankar0398-cmyk wants to merge 1 commit intolangchain-ai:mainfrom
sivashankar0398-cmyk:fix-stale-client-hook

Conversation

@sivashankar0398-cmyk
Copy link

Fixes #1840.

This change prevents the useStream hook from capturing a stale client reference
after a token refresh. The callback is now updated when the client configuration
changes, ensuring fresh authentication is always used and avoiding 403 errors.

Tests:

  • pnpm --filter @langchain/langgraph-sdk test

@changeset-bot
Copy link

changeset-bot bot commented Jan 14, 2026

⚠️ No Changeset found

Latest commit: a777dc9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

if (options.passthrough) return Promise.resolve([]);

const client = clientRef.current;
const key = getFetchHistoryKey(client, threadId, limit);
Copy link
Member

Choose a reason for hiding this comment

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

Is this still needed then?

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.

useStream hook: stale client closure causes 403 errors after token refresh

3 participants