LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
React SDK
Vue SDK
Svelte SDK
Angular SDK
LangGraph SDK
  • Ui
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Utils
  • Server
  • Stream
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
  • Store
LangGraph Checkpoint Redis
  • Shallow
  • Store
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
  • Cli
LangGraph API
LangGraph CLI
LangGraph CUA
  • Utils
LangGraph Supervisor
LangGraph Swarm
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangGraph
WebChannelsPregelPrebuiltRemote
React SDK
Vue SDK
Svelte SDK
Angular SDK
LangGraph SDK
UiClientAuthReactLoggingReact UiUtilsServerStream
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
Store
LangGraph Checkpoint Redis
ShallowStore
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
Cli
LangGraph API
LangGraph CLI
LangGraph CUA
Utils
LangGraph Supervisor
LangGraph Swarm
Language
Theme
JavaScript@langchain/langgraph-sdkstreamStreamController
Class●Since v2.0

StreamController

Copy
class StreamController

Constructors

Properties

Methods

View source on GitHub
constructor
constructor
property
messageMetadataStore: StreamStore<MessageMetadataMap>
property
queueStore: StreamStore<SubmissionQueueSnapshot<StateType>>
property
registry: ChannelRegistry
property
rootStore: StreamStore<RootSnapshot<StateType, InterruptType>>
property
subagentStore: StreamStore<SubagentMap>
property
subgraphByNodeStore: StreamStore<SubgraphByNodeMap>
property
subgraphStore: StreamStore<SubgraphMap>
property
hydrationPromise: Promise<void>
method
activate→ () => void

StrictMode-safe lifecycle hook for framework bindings.

React 18+ StrictMode intentionally mounts → unmounts → remounts components in dev to surface effect-cleanup bugs. A naive useEffect(() => () => controller.dispose()) would permanently tear the controller down on that first synthetic unmount, leaving every subsequent submit() a silent no-op.

Call activate from the bind site's effect and return the result as the effect's cleanup. The controller uses deferred disposal: a release() only schedules a dispose on the next microtask, which is cancelled if another activate() arrives before it fires (the normal StrictMode remount path).

method
cancelQueued→ Promise<boolean>

Cancel a queued submission by id. Returns true when the entry was found and removed, false otherwise.

Today this only removes the entry from the client-side mirror — once the server exposes queue cancel (roadmap A0.3) the controller will additionally issue a cancel call against the active transport.

method
clearQueue→ Promise<void>

Drop every queued submission. Server-side cancel arrives with A0.3.

method
dispose→ Promise<void>

Tear everything down.

Detaches the bound thread (so no further bind() calls reopen runtimes) and disposes every live runtime in parallel. Safe to call multiple times — subsequent calls find an empty registry and resolve immediately.

method
getThread→ ThreadStream<Record<string, unknown>> | undefined

Current underlying ThreadStream (v2 escape hatch).

method
hydrate→ Promise<void>

Fetch the checkpointed thread state and seed the root snapshot. Re-calling with a different threadId swaps the underlying ThreadStream, rewires the registry to the new thread, and resets assemblers.

method
respond→ Promise<void>
method
stop→ Promise<void>

Abort the currently tracked run and mark the controller idle.

method
submit→ Promise<void>

Submit input or a resume command to the active thread.

method
subscribeThread→ () => void

Listen for ThreadStream lifecycle (swap on thread-id change, detach on dispose). The listener fires immediately with the current thread (may be undefined).

Coordinates one thread's protocol-v2 stream and exposes stable observable projections for framework bindings.

The controller owns the root subscription, lazily binds scoped projections through ChannelRegistry, and normalizes protocol events into class-message, tool-call, discovery, interrupt, and queue stores.