HKUDS/nanobot · error · ConnectionError

Signal SSE stream closed by remote endpoint

Error message

Signal SSE stream closed by remote endpoint

What it means

Transport failure in _sse_receive_loop: the SSE stream from signal-cli ended cleanly (EOF) — the remote endpoint closed the connection — rather than erroring mid-read. The receive loop cannot continue on a closed stream.

Solutions

  1. Rely on the outer reconnect logic to re-open the SSE stream
  2. Restart signal-cli if it closes streams immediately (check its logs for crashes)
  3. Upgrade signal-cli-rest-api if it has known SSE keep-alive issues
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at nanobot/channels/signal/runtime.py:666 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HKUDS/nanobot@42f37dc4c0 (2026-08-26). Data as JSON: /api/errors/4b009967a14faab3. Report an issue: GitHub.

Appendix: source

Thrown at nanobot/channels/signal/runtime.py:666

                                    self.logger.warning(
                                        "Invalid JSON in SSE buffer: {}, data: {}",
                                        e,
                                        data_str[:200],
                                    )
                                finally:
                                    event_buffer = []

                        # "data:" line - accumulate it
                        elif line.startswith("data:"):
                            # SSE spec: strip one optional leading space after "data:".
                            event_buffer.append(line[6:] if line[5:6] == " " else line[5:])

                        # "event:" line - just log it (we only care about data)
                        elif line.startswith("event:"):
                            pass  # Ignore event type for now

                if self._running:
                    raise ConnectionError("Signal SSE stream closed by remote endpoint")

        except asyncio.CancelledError:
            self.logger.info("SSE receive loop cancelled")
            raise
        except Exception as e:
            self.logger.error("Error in SSE receive loop: {}", e)
            raise

    @asynccontextmanager  # pyright: ignore[reportDeprecated]
    async def _safe_handle(self, action: str, payload: Any = None) -> AsyncIterator[None]:
        """Swallow and log any exception from a top-level handler block.

        Logs `self.logger.error` with the action name, the exception, and a
        bounded ``repr`` of the offending payload so the offending input is
        recoverable from logs without having to correlate by timestamp.
        """
        try:
            yield

View on GitHub (pinned to 42f37dc4c0)