{"record":{"id":"d49078bd2768389d","repo":"Hmbown/CodeWhale","slug":"sse-endpoint-not-received-within-ms","errorCode":null,"errorMessage":"SSE endpoint not received within {}ms","messagePattern":"SSE endpoint not received within (.+?)ms","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/mcp/sse.rs","lineNumber":218,"sourceCode":"            }\n        }\n        Ok(())\n    }\n\n    async fn wait_for_endpoint(\n        &mut self,\n        cancel_token: &tokio_util::sync::CancellationToken,\n        endpoint_timeout: Duration,\n    ) -> Result<()> {\n        let timeout = tokio::time::sleep(endpoint_timeout);\n        tokio::pin!(timeout);\n\n        let msg = tokio::select! {\n            _ = cancel_token.cancelled() => {\n                anyhow::bail!(\"SSE transport cancelled before endpoint was discovered\");\n            }\n            _ = &mut timeout => {\n                anyhow::bail!(\n                    \"SSE endpoint not received within {}ms\",\n                    endpoint_timeout.as_millis()\n                );\n            }\n            msg = self.receiver.recv() => {\n                msg.context(\"SSE transport closed before endpoint was discovered\")?\n            }\n        };\n\n        match msg {\n            SseInbound::Endpoint(endpoint) => self.store_endpoint(&endpoint),\n            SseInbound::Message(_) => {\n                anyhow::bail!(\"MCP SSE server sent a message before declaring its endpoint\");\n            }\n        }\n    }\n\n    fn store_endpoint(&mut self, endpoint: &str) -> Result<()> {","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/mcp/sse.rs#L200-L236","documentation":"After connecting, the SSE protocol requires the server to announce its message endpoint within `endpoint_timeout`. If no endpoint event arrives in time, the client gives up with this error naming the timeout in milliseconds.","triggerScenarios":"Server connects but never sends the `endpoint` event within the configured timeout — hung/broken server, wrong transport negotiation, or a very slow server with too small a timeout.","commonSituations":"Server that accepts the SSE connection but stalls; an intermediary eating the first event; extremely loaded server; timeout configured too aggressively (a few hundred ms).","solutions":["Increase the endpoint timeout to tolerate slow servers","Verify the server actually implements the SSE transport and sends an endpoint event on connect","Check intermediaries (proxy, auth layer) for buffering that withholds the first event","Retry the connection; a one-off stall may clear"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for attempt in 0..3 {\n    match wait_for_endpoint(...).await {\n        Err(e) if e.to_string().contains(\"not received within\") && attempt < 2 => continue,\n        other => break other,\n    }\n}","preventionTips":["Set the endpoint timeout generously (seconds, not milliseconds)","Verify servers implement the SSE endpoint announcement","Watch for proxies buffering the first event"],"tags":["mcp","sse","timeout","protocol"],"backgroundTag":"request-timeout","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}