{"record":{"id":"8f066a0650cf9828","repo":"langchain-ai/langgraph","slug":"this-streamchannel-is-bound-to-async-mode-use-a","errorCode":null,"errorMessage":"This StreamChannel is bound to async mode — use 'async for' instead.","messagePattern":"This StreamChannel is bound to async mode — use 'async for' instead\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"libs/langgraph/langgraph/stream/stream_channel.py","lineNumber":172,"sourceCode":"\n    # ------------------------------------------------------------------\n    # Sync iteration (caller-driven pump)\n    # ------------------------------------------------------------------\n\n    def __iter__(self) -> Iterator[T]:\n        \"\"\"Subscribe and return a sync cursor. Can be called only once.\n\n        Raises:\n            TypeError: If the channel is unbound or bound to async mode.\n            RuntimeError: If the channel already has a subscriber.\n        \"\"\"\n        if self._is_async is None:\n            raise TypeError(\n                \"StreamChannel has not been bound yet. \"\n                \"Register the transformer with a StreamMux first.\"\n            )\n        if self._is_async:\n            raise TypeError(\n                \"This StreamChannel is bound to async mode — use 'async for' instead.\"\n            )\n        if self._subscribed:\n            raise RuntimeError(\n                \"StreamChannel already has a subscriber; use .tee(n) for fan-out.\"\n            )\n        self._subscribed = True\n        return self._sync_cursor()\n\n    def _sync_cursor(self) -> Iterator[T]:\n        while True:\n            if self._items:\n                _stamp, item = self._items.popleft()\n                yield item\n            elif self._closed:\n                if self._error is not None:\n                    raise self._error\n                return","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/langchain-ai/langgraph/blob/38031739e551638e373fb553453256c23feeb41f/libs/langgraph/langgraph/stream/stream_channel.py#L154-L190","documentation":"Raised by StreamChannel.__iter__ when a sync iteration is attempted on a channel whose mode flag _is_async is True. The channel was bound to async mode when its transformer was registered with a StreamMux, so its data is driven by an async pump; consuming it with a plain for loop or next() is a mode mismatch, not a state error. The fix is to consume via 'async for' (i.e. __aiter__/__anext__), or rebind the transformer to a sync mux.","triggerScenarios":"Thrown at libs/langgraph/langgraph/stream/stream_channel.py:172 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use `async for item in ch` on async-bound channels","Run the graph with sync stream() so the channel binds to sync mode"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"38031739e551638e373fb553453256c23feeb41f","analyzedAt":"2026-08-26T18:02:49.312Z","contentChangedAt":"2026-08-26T18:02:49.312Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}