# thread.isLoading remains \`true\` even after stream completion due to delayed \`history\` fetch

**URL:** <https://forum.langchain.com/t/thread-isloading-remains-true-even-after-stream-completion-due-to-delayed-history-fetch/529>\
**Category:** LangGraph\
**Tags:** js-help\
**Created:** [July 17, 2025, 7:02pm UTC](https://forum.langchain.com/t/thread-isloading-remains-true-even-after-stream-completion-due-to-delayed-history-fetch/529 "2025-07-17T19:02:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dhanush-Ma](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/dhanush-ma/32/243_2.png) [@Dhanush-Ma](https://forum.langchain.com/u/Dhanush-Ma)\
**Post date:** [July 17, 2025, 7:02pm UTC](https://forum.langchain.com/t/thread-isloading-remains-true-even-after-stream-completion-due-to-delayed-history-fetch/529/1 "2025-07-17T19:02:11Z")

</div>

## 🐛 Bug Report: `isLoading` remains `true` even after stream completion due to delayed `history` fetch

### 📌 Context

We are using `stream.submit()` from the LangGraph SDK to stream messages with `streamMode: ["custom"]`. During the streaming process, `stream.isLoading` is set to `true` — which is expected. However, **it remains `true` even after streaming completes**. This introduces unnecessary UI blocking and delays the feedback to the user.

**Code snippet:**

```ts
stream.submit(
  {
    messages: [...toolMessages, ...messages],
    userId: user!.id,
    currentBrandContextId: selectedBrandId,
  },
  {
    streamMode: ["custom"],
    optimisticValues: (prev) => ({
      ...prev,
      messages: [...(prev.messages ?? []), ...toolMessages, ...messages],
    }),
  }
);

```

Expected Behavior  
Once the streaming of response chunks is finished — i.e., the for await (const chunk of stream) equivalent is complete — we expect isLoading to be set to false.

Actual Behavior  
What seems to be happening is:

stream.submit() starts the stream.

Streaming completes (we receive the final chunk).

Then, the SDK internally triggers a history fetch request (likely via refetch() or a similar method).

isLoading remains true until this secondary history call also completes.

As a result, the UI is blocked even after the streaming has concluded, leading to a delayed perception of responsiveness.

Why this matters  
For most UI implementations, isLoading is interpreted as “stream in progress”.

Fetching history can be slower and shouldn’t block the streaming UX.

From a user’s perspective, the spinner or loading indicator persists longer than expected, creating confusion or perceived slowness.

---

<div class="post-metadata">

**Author:** ![muddhit](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@muddhit](https://forum.langchain.com/u/muddhit)\
**Post date:** [July 27, 2025, 5:12pm UTC](https://forum.langchain.com/t/thread-isloading-remains-true-even-after-stream-completion-due-to-delayed-history-fetch/529/2 "2025-07-27T17:12:41Z")

</div>

Facing the same issue, can someones tell how to solve this with OSS version. @nithin

---

<div class="post-metadata">

**Author:** ![Dhanush-Ma](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/dhanush-ma/32/243_2.png) [@Dhanush-Ma](https://forum.langchain.com/u/Dhanush-Ma)\
**Post date:** [August 1, 2025, 4:43pm UTC](https://forum.langchain.com/t/thread-isloading-remains-true-even-after-stream-completion-due-to-delayed-history-fetch/529/3 "2025-08-01T16:43:06Z")

</div>

@nithin any help on this?

---

<div class="post-metadata">

**Author:** ![liam-langchain](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/liam-langchain/32/451_2.png) [@liam-langchain](https://forum.langchain.com/u/liam-langchain)\
**Post date:** [August 2, 2025, 7:42am UTC](https://forum.langchain.com/t/thread-isloading-remains-true-even-after-stream-completion-due-to-delayed-history-fetch/529/4 "2025-08-02T07:42:55Z")

</div>

Hi Dhanush,

Thank you so much for bringing this to our attention and for your help so far. I also saw your bug report [here.](https://github.com/langchain-ai/langgraph/issues/5564) Would you be able to share your full graph implementation so we can take a deeper look and try to triage this issue?

---

<div class="post-metadata">

**Author:** ![Dhanush-Ma](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/dhanush-ma/32/243_2.png) [@Dhanush-Ma](https://forum.langchain.com/u/Dhanush-Ma)\
**Post date:** [August 2, 2025, 8:47am UTC](https://forum.langchain.com/t/thread-isloading-remains-true-even-after-stream-completion-due-to-delayed-history-fetch/529/5 "2025-08-02T08:47:17Z")

</div>

Hi Liam,

I don’t believe this is related to the graph implementation. Even with a minimal graph setup, including your own examples, the issue still occurs.

As the number of thread messages and the context grow, the SDK’s history fetch API call becomes increasingly slow. The time taken seems to scale exponentially with the length of the message list.

Additionally, I wanted to check if the `streamMode` option in the SDK is necessary in this context. Could you help clarify its relevance here?

---

<div class="post-metadata">

**Author:** ![Dhanush-Ma](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/dhanush-ma/32/243_2.png) [@Dhanush-Ma](https://forum.langchain.com/u/Dhanush-Ma)\
**Post date:** [August 6, 2025, 5:24pm UTC](https://forum.langchain.com/t/thread-isloading-remains-true-even-after-stream-completion-due-to-delayed-history-fetch/529/6 "2025-08-06T17:24:16Z")

</div>

@liam-langchain Any update?

---

<div class="post-metadata">

**Author:** ![RashimNarayanTiku](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/rashimnarayantiku/32/1026_2.png) [@RashimNarayanTiku](https://forum.langchain.com/u/RashimNarayanTiku)\
**Post date:** [September 19, 2025, 8:42am UTC](https://forum.langchain.com/t/thread-isloading-remains-true-even-after-stream-completion-due-to-delayed-history-fetch/529/7 "2025-09-19T08:42:03Z")

</div>

@liam-langchain Please let us know if there are any updates regarding this.

---

<div class="post-metadata">

**Author:** ![Dhanush-Ma](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/dhanush-ma/32/243_2.png) [@Dhanush-Ma](https://forum.langchain.com/u/Dhanush-Ma)\
**Post date:** [October 8, 2025, 3:24pm UTC](https://forum.langchain.com/t/thread-isloading-remains-true-even-after-stream-completion-due-to-delayed-history-fetch/529/8 "2025-10-08T15:24:15Z")

</div>

@liam-langchain Are you working on this, still not addressed.
