Files
OmniRoute/tests
Markus Hartung d9041b7070 fix(sse): bound the chatgpt-session stream-open gate with a deadline
The gate withholds the HTTP response until the first event that also counts
as committed output on the buffered path, so both paths agree on failover
status. While it is closed nothing reaches the client — not even a keepalive,
since the first byte commits the 200 — and a turn here runs in a real browser
that can think for a long time, so a client with an idle timeout could hang up
on a perfectly healthy turn.

Race the gate against CHATGPT_SESSION_STREAM_OPEN_TIMEOUT_MS (30s, overridable
per call through the new options argument). A committing event or an error
still wins exactly as before; only when the deadline elapses with neither does
the stream open anyway and keep consuming the same iterator, replaying the
buffered reasoning after the role chunk so nothing is lost or reordered. The
in-flight next() the deadline outran is carried into the stream body instead of
being abandoned, otherwise its event would vanish behind a second next(). The
timer is unref'd and cleared on every exit path.

Every failure that needs a real HTTP status — no browser, missing or expired
credentials, rate limiting, an incompatible route — surfaces within seconds,
far inside the window.
2026-09-02 15:16:05 -03:00
..
2026-08-26 14:25:01 -03:00