External annotations SSE stream times out after 10s idle timeout in Bun
/api/external-annotations/stream can be terminated after 10 seconds of inactivity with:
[Bun.serve]: request timed out after 10 seconds. Pass `idleTimeout` to configure.
Environment
Observed in the following environment:
- OpenCode v1.3.6
- Plannotator v0.16.0
Root cause
Bun.serve uses a default idleTimeout of 10 seconds.
Our external annotations SSE heartbeat is 30 seconds (HEARTBEAT_INTERVAL_MS in packages/shared/external-annotation.ts), so the connection can sit idle long enough for Bun to close it.
The SSE response is created in:
packages/server/external-annotations.ts
and returned by the Bun servers used for:
packages/server/index.tspackages/server/review.tspackages/server/annotate.ts
At the moment, these SSE responses do not disable or extend Bun's per-request timeout.
Reproduction
- Open a Plannotator UI that connects to
/api/external-annotations/stream - Leave it idle without incoming annotation events
- After ~10 seconds, Bun logs:
[Bun.serve]: request timed out after 10 seconds. Pass `idleTimeout` to configure.
Expected behavior
The SSE connection should remain open while idle.
Suggested fix
Before returning the SSE response, disable or extend the request timeout for that stream, e.g. with Bun's per-request timeout handling (server.timeout(req, 0)), or otherwise ensure the stream is not subject to the default 10-second idle timeout.
Reducing the heartbeat interval would also help, but the main issue is that the SSE request still uses Bun's default timeout.
Released as 0.16.1