{"record":{"id":"848263ef993ad4de","repo":"langchain-ai/langgraph","slug":"asyncthreadstream-is-closed-and-cannot-be-re-enter","errorCode":null,"errorMessage":"AsyncThreadStream is closed and cannot be re-entered.","messagePattern":"AsyncThreadStream is closed and cannot be re-entered\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"libs/sdk-py/langgraph_sdk/_async/stream.py","lineNumber":1245,"sourceCode":"        self.values = _ValuesProjection(self)\n        self.messages = _MessagesProjection(self, namespace=[])\n        self.tool_calls = _ToolCallsProjection(self, namespace=[])\n        self.subgraphs = _SubgraphsProjection(self, scope=())\n        self.subagents = self.subgraphs\n        self.extensions = _ExtensionsProjection(self, namespace=[])\n\n    @property\n    def _controller(self) -> AsyncThreadStream:\n        \"\"\"Return self as the subscription controller (duck-type compatible with StreamController).\n\n        Exposes `_subscriptions` so tests can verify subscription counts via\n        `thread._controller._subscriptions` without requiring a separate controller object.\n        \"\"\"\n        return self\n\n    async def __aenter__(self) -> AsyncThreadStream:\n        if self._closed:\n            raise RuntimeError(\"AsyncThreadStream is closed and cannot be re-entered.\")\n        transport_cls = (\n            ProtocolWebSocketTransport\n            if self._transport_kind == \"websocket\"\n            else ProtocolSseTransport\n        )\n        self._transport = transport_cls(\n            client=self._http.client,\n            thread_id=self.thread_id,\n            headers=self._headers,\n            max_queue_size=self._max_queue_size,\n        )\n        # Create the run-done future here (async context guarantees a running loop).\n        self._run_done = asyncio.get_running_loop().create_future()\n        # Start the lifecycle watcher immediately so reattach and thread.output\n        # work without a preceding run.start call.\n        self._ensure_lifecycle_watcher_running()\n        return self\n","sourceCodeStart":1227,"sourceCodeEnd":1263,"githubUrl":"https://github.com/langchain-ai/langgraph/blob/38031739e551638e373fb553453256c23feeb41f/libs/sdk-py/langgraph_sdk/_async/stream.py#L1227-L1263","documentation":"Error \"AsyncThreadStream is closed and cannot be re-entered.\" thrown in langchain-ai/langgraph.","triggerScenarios":"Thrown at libs/sdk-py/langgraph_sdk/_async/stream.py:1245 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"38031739e551638e373fb553453256c23feeb41f","analyzedAt":"2026-08-26T18:02:49.312Z","schemaVersion":2},"datasetVersion":"2026-08-26T21:11:00.512Z"}