{"record":{"id":"0277544a37b20025","repo":"langchain-ai/langgraph","slug":"streamchannel-already-has-a-subscriber-use-atee","errorCode":null,"errorMessage":"StreamChannel already has a subscriber; use .atee(n) for fan-out.","messagePattern":"StreamChannel already has a subscriber; use \\.atee\\(n\\) for fan-out\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"libs/langgraph/langgraph/stream/stream_channel.py","lineNumber":219,"sourceCode":"\n    def __aiter__(self) -> AsyncIterator[T]:\n        \"\"\"Subscribe and return an async cursor. Can be called only once.\n\n        Raises:\n            TypeError: If the channel is unbound or bound to sync 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 not self._is_async:\n            raise TypeError(\n                \"This StreamChannel is bound to sync mode — use 'for' instead.\"\n            )\n        if self._subscribed:\n            raise RuntimeError(\n                \"StreamChannel already has a subscriber; use .atee(n) for fan-out.\"\n            )\n        self._subscribed = True\n        return self._async_cursor()\n\n    async def _async_cursor(self) -> AsyncIterator[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\n            elif self._arequest_more is not None:\n                if not await self._arequest_more():\n                    if not self._items and not self._closed:\n                        return","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/langchain-ai/langgraph/blob/38031739e551638e373fb553453256c23feeb41f/libs/langgraph/langgraph/stream/stream_channel.py#L201-L237","documentation":"Raised by StreamChannel.__aiter__ when an async subscriber already exists. Async cursors also allow only one subscriber; a second __aiter__ call is rejected to prevent concurrent item theft. Use .atee(n) for async fan-out.","triggerScenarios":"Thrown at libs/langgraph/langgraph/stream/stream_channel.py:219 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use ch.atee(n) to create multiple async cursors","Iterate the channel from a single async consumer"],"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"}