evolver icon indicating copy to clipboard operation
evolver copied to clipboard

SSE event stream 404 on latest v1.91.1 — endpoint mismatch: client requests /a2a/events, Hub serves /a2a/events/stream

Open StackWanderer775 opened this issue 4 months ago • 3 comments

{ "title": "SSE event stream 404 on latest v1.91.1 — endpoint mismatch: client requests /a2a/events, Hub serves /a2a/events/stream", "body": "# SSE stream never connects on latest v1.91.1 — endpoint path mismatch\n\n## Summary\n\nOn @evomap/[email protected] (current npm latest), the Hub SSE event stream\nfails to connect on every attempt. Heartbeat works fine; SSE fails with\neventsource_not_available and re-exponentially-backs to a 120s interval,\nleaving the evolution loop completely stalled.\n\nRoot cause identified: evolver constructs the SSE URL as /a2a/events\n(or /a2a/stream), but the current Hub only exposes the SSE endpoint at\nGET /a2a/events/stream?node_id=....\n\n## Environment\n\n- evolver: 1.91.1 (npm view @evomap/evolver version → 1.91.1)\n- OS: Linux aarch64 (Raspberry Pi, 1.8GB RAM), Ubuntu 22.04\n- Node: 24.18.0\n- Hub: https://evomap.ai (default)\n- Node ID: 16-hex node_fb019fe4f7276a1b (format valid, 12–32 hex)\n\n## Expected behavior\n\nevolver --loop establishes a stable SSE connection to the Hub and\nreceives real-time evolution events (no sse_open_failed logs).\n\n## Actual behavior\n\nEvery SSE attempt fails and enters exponential backoff:\n\njson\n{\"ts\":\"2026-07-12T19:36:10.260Z\",\"type\":\"heartbeat_ok\",\"tick\":3,\"fpSent\":false,\"pendingEvents\":false}\n{\"ts\":\"2026-07-12T19:36:10.780Z\",\"type\":\"sse_open_failed\",\"error\":\"eventsource_not_available\",\"reconnectInMs\":120000}\n{\"ts\":\"2026-07-12T19:38:10.786Z\",\"type\":\"sse_open_failed\",\"error\":\"eventsource_not_available\",\"reconnectInMs\":120000}\n\n\nheartbeat_ok succeeds on every tick; SSE never recovers.\n\n## Reproduction\n\nbash\nexport A2A_HUB_URL=https://evomap.ai\nexport A2A_NODE_ID=<16-hex-node-id>\nexport A2A_NODE_SECRET=<secret>\nnode $(which evolver) --loop\n\n\nObserve evolver_loop.log: heartbeat ok, SSE eventsource_not_available\nevery 2 minutes forever.\n\n## Diagnosis (evidence)\n\n1. GET /a2a/events → HTTP 404\n2. GET /a2a/stream → HTTP 404\n3. Both 404 responses include a suggestions field listing the actual\n registered route:\n\njson\n{\"method\":\"GET\",\"path\":\"/a2a/events/stream\",\n \"description\":\"SSE event stream for real-time agent notifications (?node_id)\"}\n\n\n4. GET /a2a/events/stream?node_id=... → HTTP 200, SSE stream opens\n successfully (verified with curl).\n\n5. Heartbeat with same credentials works correctly:\n\njson\n{\"ok\":true,\"response\":{\"node_status\":\"active\",\"your_node_id\":\"node_fb019fe4f7276a1b\"}}\n\n\nSo node_id format, auth, and Hub reachability are all fine.\nThe SSE URL is simply pointing at a path that no longer exists.\n\n## Relevant prior issue\n\nGitHub Issue #380 describes the same SSE reconnect loop. Official response\n(autogame-17, 2026-04-18) noted that the SSE reconnect loop lives in the\nobfuscated src/gep/a2aProtocol.js and that the fix had shipped in\nv1.67.x–v1.69.1. However the problem persists unchanged in v1.91.1.\n\nThe v1.69.1 era fix apparently targeted a different SSE failure mode\n(connection drops / auth storms). The current failure is a plain 404\nendpoint mismatch — a stale hardcoded path in the SSE URL builder.\n\n## Request\n\n1. Please fix the SSE URL in src/gep/a2aProtocol.js (or whichever module\n constructs the stream URL) to use GET /a2a/events/stream?node_id=...\n matching the current Hub route.\n2. Confirm whether /a2a/events/poll is also still removed from the Hub,\n as EVOLVER_SSE_DISABLED=1 currently has no working poll fallback\n (GET /a2a/events/poll → 404).\n\nNo credentials are included in this report. No files were modified except\nlocal env vars for testing." }

StackWanderer775 avatar Jul 12 '26 19:07 StackWanderer775

🤖 @bjw9808 这条 issue 在你负责的仓库,麻烦认领或跟进一下。(agent-control 自动提醒;未自动接入)

owenshen0907 avatar Jul 12 '26 19:07 owenshen0907

I will handle this

bjw9808 avatar Jul 13 '26 02:07 bjw9808

Root-caused and fixed on the client side (fix committed in the private dev repo, going through release).

The endpoint path was actually not the problem in the shipped code — hubOpenEventStream() already builds GET /a2a/events/stream?node_id=...&duration_ms=..., matching the Hub route you confirmed with curl. The real gap on v1.91.1: on a bare Node CLI there is no global EventSource (Node's is still behind a flag / experimental) and the optional eventsource package is not a dependency, so the function returned eventsource_not_available before ever making a request — which is exactly the log line you saw, and why heartbeat (plain hubFetch POST) worked while SSE never connected.

Fix: added a hubFetch-based SSE reader used automatically when no EventSource constructor is available. It issues the same GET /a2a/events/stream?node_id=... over the existing TLS-pinned client and parses data:/event:/id: frames, so the stream now connects on a stock Node install instead of backing off to 120s forever. The stream also gets a dedicated undici dispatcher with bodyTimeout disabled so a minutes-idle SSE connection isn't cut by the 30s pool.

On your second question — EVOLVER_SSE_DISABLED=1 + poll fallback: /a2a/events/poll is a separate client path (_fetchHubEvents / self-driving long-poll) and is unaffected by this change; if the Hub is returning 404 there, that's a Hub-side route question rather than a client bug. Will confirm the exact poll status separately.

Fix will land in the next release; this issue tracks it.

autogame-17 avatar Jul 13 '26 15:07 autogame-17