{"record":{"id":"710bc7a3d3a6409b","repo":"HKUDS/Vibe-Trading","slug":"http-client-not-initialized-for-signal-sse-stream","errorCode":null,"errorMessage":"HTTP client not initialized for Signal SSE stream","messagePattern":"HTTP client not initialized for Signal SSE stream","errorType":"error_code","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent/src/channels/signal.py","lineNumber":594,"sourceCode":"                else:\n                    self.logger.debug(\n                        f\"Signal message sent, timestamp: {response.get('result', {}).get('timestamp')}\"\n                    )\n\n        except Exception:\n            self.logger.exception(\"Error sending Signal message\")\n            raise\n        finally:\n            # Keep typing active across progress updates; stop on the final reply.\n            if not is_progress_message:\n                # Avoid immediate START->STOP for fast responses, which can be invisible\n                # in some Signal clients. Let indicator expire naturally (~15s).\n                await self._stop_typing(msg.chat_id, send_stop=False)\n\n    async def _sse_receive_loop(self) -> None:\n        \"\"\"Receive messages via Server-Sent Events (HTTP mode).\"\"\"\n        if not self._http:\n            raise RuntimeError(\"HTTP client not initialized for Signal SSE stream\")\n\n        self.logger.info(\"Started Signal message receive loop (SSE)\")\n\n        try:\n            async with self._http.stream(\"GET\", \"/api/v1/events\") as response:\n                if response.status_code != 200:\n                    raise ConnectionError(\n                        f\"SSE connection failed with status {response.status_code}\"\n                    )\n\n                self.logger.info(\"Subscribed to Signal messages via SSE\")\n\n                # Buffer for accumulating SSE data across multiple lines\n                event_buffer = []\n\n                async for line in response.aiter_lines():\n                    if not self._running:\n                        break","sourceCodeStart":576,"sourceCodeEnd":612,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/channels/signal.py#L576-L612","documentation":"Internal invariant error: the SSE receive loop was started before the httpx AsyncClient was created, indicating a lifecycle/state bug rather than an environment problem.","triggerScenarios":"Calling _sse_receive_loop directly, or start() flow that skips HTTP client initialization (misconfigured mode, partial failure during startup).","commonSituations":"Custom code invoking internal methods, or an exception during _start_http_mode leaving half-initialized state.","solutions":["Don't call _sse_receive_loop directly; use start()","Check logs for earlier startup errors that prevented client init","Report as a bug if it happens via normal start() flow"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"assert channel._http is not None, 'channel not started'","typeGuard":"def is_signal_http_ready(ch) -> bool:\n    return getattr(ch, '_http', None) is not None","tryCatchPattern":null,"preventionTips":["Never call internal loops directly; use start()","Check startup logs for earlier failures"],"tags":["signal","internal","lifecycle"],"backgroundTag":"client-not-initialized","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}