This stream has already been locked for exclusive reading by another reader #289

Closed
opened 2026-02-15 18:15:32 -05:00 by yindo · 5 comments
Owner

Originally created by @simon28082 on GitHub (Jun 21, 2025).

I'm developing an IOS app using React Native, and I'm currently finding that langgraph JS's handling of streaming is not compatible in React Naive, and always reports an error that the stream is being read twice!


The Core Problem

The @langchain/langgraph package's internal state management and node transition mechanisms heavily rely on the Web Streams API (ReadableStream). React Native's JavaScript execution environments (Hermes or JavaScriptCore) lack full or native compatibility with this API, leading to conflicts when LangGraph attempts to control its internal data flow.


Root Cause

Despite our attempts to use polyfills (which simulate newer functionalities in older environments), these polyfills cannot perfectly replicate the streaming environment found in Node.js or modern browsers. This results in the "This stream has already been locked" error. This indicates that the problem doesn't lie with the LLM's response itself, but rather with LangGraph's architecture.


Attempts and Failures

Our attempt to set streaming: false failed because it only affected how OpenAI responded and did not alter LangGraph's internal mechanism of using streams to pass state.


Affected Versions

The following packages and their versions are currently causing compatibility issues in the project:

Category Package Name/Component Version Role Core Issue
Core @langchain/langgraph ^0.3.4 Provides Agent and graph state management Its stream processing is incompatible.
Environment react-native 0.79.4 Provides the mobile application runtime environment Its JS engine differs from the Web.
Framework expo ~53.0.12 Toolchain for managing and building React Native projects
Core Dependency react 19.0.0 Core library driving the UI
Related @langchain/core ^0.3.61 LangChain's core types and interfaces
Related @langchain/openai ^0.5.15 OpenAI integration It is compatible on its own.
Originally created by @simon28082 on GitHub (Jun 21, 2025). I'm developing an IOS app using React Native, and I'm currently finding that langgraph JS's handling of streaming is not compatible in React Naive, and always reports an error that the stream is being read twice! --- ## The Core Problem The **`@langchain/langgraph`** package's internal **state management** and **node transition mechanisms** heavily rely on the **Web Streams API (`ReadableStream`)**. React Native's JavaScript execution environments (**Hermes** or **JavaScriptCore**) lack full or native compatibility with this API, leading to conflicts when LangGraph attempts to control its internal data flow. --- ## Root Cause Despite our attempts to use **polyfills** (which simulate newer functionalities in older environments), these polyfills cannot perfectly replicate the streaming environment found in Node.js or modern browsers. This results in the **`"This stream has already been locked"`** error. This indicates that the problem doesn't lie with the LLM's response itself, but rather with LangGraph's architecture. --- ## Attempts and Failures Our attempt to set `streaming: false` failed because it only affected how OpenAI responded and did not alter LangGraph's internal mechanism of using streams to pass state. --- ## Affected Versions The following packages and their versions are currently causing compatibility issues in the project: | Category | Package Name/Component | Version | Role | Core Issue | | :-------------- | :------------------------- | :--------- | :---------------------------------------------------- | :--------------------------------------------------------------------- | | Core | `@langchain/langgraph` | `^0.3.4` | Provides Agent and graph state management | Its stream processing is incompatible. | | Environment | `react-native` | `0.79.4` | Provides the mobile application runtime environment | Its JS engine differs from the Web. | | Framework | `expo` | `~53.0.12` | Toolchain for managing and building React Native projects | | | Core Dependency | `react` | `19.0.0` | Core library driving the UI | | | Related | `@langchain/core` | `^0.3.61` | LangChain's core types and interfaces | | | Related | `@langchain/openai` | `^0.5.15` | OpenAI integration | It is compatible on its own. |
yindo added the bug label 2026-02-15 18:15:32 -05:00
yindo closed this issue 2026-02-15 18:15:32 -05:00
Author
Owner

@MeisterJustice commented on GitHub (Jun 23, 2025):

I'm facing the exact same issue. the useStream hook streams responses in chunks on my Nextjs app, but it doesn't behave the same in my react native app. I have the exact same code from the documentation in both projects.

So basically, it works in my React Native project, but it doesn't stream the agent responses. It waits until the agent response ends, then sends it to me.

@MeisterJustice commented on GitHub (Jun 23, 2025): I'm facing the exact same issue. the useStream hook streams responses in chunks on my Nextjs app, but it doesn't behave the same in my react native app. I have the exact same code from the documentation in both projects. So basically, it works in my React Native project, but it doesn't stream the agent responses. It waits until the agent response ends, then sends it to me.
Author
Owner

@an-upfeat commented on GitHub (Jul 14, 2025):

any update on this? I got same error..

@an-upfeat commented on GitHub (Jul 14, 2025): any update on this? I got same error..
Author
Owner

@an-upfeat commented on GitHub (Jul 15, 2025):

after rollback to 0.2.61, error is gone.

@an-upfeat commented on GitHub (Jul 15, 2025): after rollback to 0.2.61, error is gone.
Author
Owner

@younes200 commented on GitHub (Aug 15, 2025):

The issue occurs also without streaming chain.invoke, works fine on 0.2.61

@younes200 commented on GitHub (Aug 15, 2025): The issue occurs also without streaming `chain.invoke`, works fine on 0.2.61
Author
Owner

@jasonstroud-fg commented on GitHub (Oct 1, 2025):

@MeisterJustice I am having the exact same issue with you - it's not streaming on my React Native project. Were you able to find any workarounds? I tried to upgrade the langgraph packages to the latest version, but it didn't fix the issue.

@jasonstroud-fg commented on GitHub (Oct 1, 2025): @MeisterJustice I am having the exact same issue with you - it's not streaming on my React Native project. Were you able to find any workarounds? I tried to upgrade the langgraph packages to the latest version, but it didn't fix the issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#289