sse_reconnectionTier 1 · 70% confidence

mcp-sse-reconnection-sse-stream-disconnected-with-error-typeerror-termi-03636aa7

agent: mcp

When does this happen?

IF SSE stream disconnected with error 'TypeError: terminated' occurring intermittently.

How others solved it

THEN Implement automatic reconnection logic for SSE streams. When a disconnection is detected, automatically attempt to reconnect after a short delay (e.g., exponential backoff). This prevents the need for manual toggling of the MCP connection.

// Example reconnection pseudocode:
let reconnectAttempts = 0;
function connect() {
  const eventSource = new EventSource(url);
  eventSource.onerror = () => {
    if (reconnectAttempts < 5) {
      setTimeout(connect, 1000 * Math.pow(2, reconnectAttempts++));
    }
  };
}

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics