Files
Ben DavisandClaude Opus 5 c696e04e81 fix: resume Hermes sessions off the status stream instead of blocking it
Restarting the gateway left every existing thread dead: the follow-up turn
failed "Call session.ensure before starting a turn" and stayed that way.

The reconnect trigger fired correctly — generation changed, the session was
present — but it awaited `session.ensure` inside the `Stream.runForEach`
handler for the status stream. That request's reply is delivered by the
broker's *other* stream, and cannot be processed until the handler returns,
so the resume deadlocked against itself and only unwedged on the 30s request
timeout. The frame never reached the plugin, the thread kept a session id the
restarted plugin had never issued, and every later status event queued behind
the stalled handler.

Fork the resume instead. The handler returns immediately, the reply lands,
and later reconnects are still processed while an earlier resume is in
flight.

Diagnosed from live instrumentation on both halves, after unit tests using a
synchronously-replying fake broker passed against the bug. The plugin logs
showed `session.ensure` arriving at the *old* process id and the new one
rejecting `turn.start` with an empty session map; the server logs showed the
reconnect detected, then exactly 30s of silence.

The regression test withholds the `session.ensure` reply and asserts a second
reconnect is still observed, which fails without the fork and needs no timers.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
2026-07-25 02:10:56 -07:00
..