Docs issue: await agent.streamEvents() is complained by TypeScript because it's not Promise #225

Closed
opened 2026-02-15 17:17:32 -05:00 by yindo · 2 comments
Owner

Originally created by @riywo on GitHub (Apr 7, 2025).

Most of the documentation mentions like below (e.g. https://langchain-ai.github.io/langgraphjs/how-tos/stream-tokens/?h=stream+events#the-streamevents-method):

const eventStream = await agent.streamEvents(...);

This works at runtime, however, TypeScript and typescript-eslint complains like below:

Image

I guess the reason is the type definition of this function isn't Promise<>:
https://github.com/langchain-ai/langgraphjs/blob/8abd32cc53db9aaf421308361b40feeeda955ec4/libs/langgraph/src/pregel/remote.ts#L362-L367

Originally created by @riywo on GitHub (Apr 7, 2025). Most of the documentation mentions like below (e.g. https://langchain-ai.github.io/langgraphjs/how-tos/stream-tokens/?h=stream+events#the-streamevents-method): ```ts const eventStream = await agent.streamEvents(...); ``` This works at runtime, however, TypeScript and typescript-eslint complains like below: <img width="1066" alt="Image" src="https://github.com/user-attachments/assets/08ac04d5-949f-4c58-8cb9-28e77446afdf" /> I guess the reason is the type definition of this function isn't `Promise<>`: https://github.com/langchain-ai/langgraphjs/blob/8abd32cc53db9aaf421308361b40feeeda955ec4/libs/langgraph/src/pregel/remote.ts#L362-L367
yindo added the documentation label 2026-02-15 17:17:32 -05:00
yindo closed this issue 2026-02-15 17:17:32 -05:00
Author
Owner

@riywo commented on GitHub (Apr 7, 2025):

Ah, or it looks like await is not needed as TS says.

The code below works, too:

const stream = agent.streamEvents();
for await (const event of stream) {
   ...
}
@riywo commented on GitHub (Apr 7, 2025): Ah, or it looks like `await` is not needed as TS says. The code below works, too: ```ts const stream = agent.streamEvents(); for await (const event of stream) { ... } ```
Author
Owner

@benjamincburns commented on GitHub (Apr 28, 2025):

Should be addressed in documentation, indeed.

@benjamincburns commented on GitHub (Apr 28, 2025): Should be addressed in documentation, indeed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#225