piker/ai/prompt-io/opencode
Gud Boi b95e7c796e .data: reconnect after websocket reader close errors
A Binance Ping racing local socket closure makes trio-websocket's
reader send a Pong while wsproto is LOCAL_CLOSING. That reader
nursery error escapes proxy_msgs(), then tears down brokerd and
pikerd instead of restoring quote delivery.

Classify NoBsWs.recon_errors around the entire websocket context,
with collapse_eg() outside it so a singleton reader exit group
reaches the reconnect handler. Invalidate the stale connected
event and socket reference before retrying. Keep retry sleep
unshielded so parent cancellation stops recovery promptly.

Deats,
- Add real loopback websocket coverage: TCP, handshake, Ping,
  reader dispatch and wsproto's actual Pong validation.
- Control only the first client Ping's protocol-state ordering,
  withholding its Close frame to prevent a peer response racing
  the deterministic LOCAL_CLOSING reproducer.
- Require fresh data on a replacement connection, plus exactly
  one connection when cancelling at the reader or retry boundary.
- Use RuntimeError for the unexpected-failure control:
  LocalProtocolError is now a recoverable connection failure.
- Preserve the original unexpected exception with bare raise,
  and assert its identity in the test. Log recoverable errors
  with the websocket URL and the underlying traceback.

This is a local follow-up, not another downstream cherry-pick.
The earlier wrapper suppressed escaped communication failures;
97eb8347 deliberately re-raised them. Retain that outer error
visibility rather than restoring suppression without recovery.
The isolated baseline reproduces the live Pong failure; all 13
selected Binance/websocket cases pass with this fix. Human live
qualification remains separate from these loopback regressions.

Follow-up-to: 97eb834799
Original-equivalent: d50ab6124c
Related-history: 3d83b61f3f
Prompt-IO: ai/prompt-io/opencode/20261028T160846Z_7242dcb9_websocket_close.md

(this patch was generated in some part by `opencode` using
`gpt-6.1-sol` (`openai`))
2026-10-28 12:48:06 -04:00
..
20260811T205826Z_06d5ea5d_prompt_io.md Fix IB `MethodProxy` response routing 2026-10-21 20:50:38 -04:00
20260811T205826Z_06d5ea5d_prompt_io.raw.md Fix IB `MethodProxy` response routing 2026-10-21 20:50:38 -04:00
20260813T202402Z_12b0d66e_prompt_io.md .data: isolate cached feed stream consumers 2026-10-21 20:50:38 -04:00
20260813T202402Z_12b0d66e_prompt_io.raw.md .data: isolate cached feed stream consumers 2026-10-21 20:50:38 -04:00
20260813T230744Z_ddac3553_prompt_io.md .ib.feed: cache quote channel contexts 2026-10-21 20:50:38 -04:00
20260813T230744Z_ddac3553_prompt_io.raw.md .ib.feed: cache quote channel contexts 2026-10-21 20:50:38 -04:00
20260820T163519Z_5f631e19_prompt_io.md Normalize registrar addrs with `wrap_address()` 2026-10-07 03:10:41 -04:00
20260820T163519Z_5f631e19_prompt_io.raw.md Normalize registrar addrs with `wrap_address()` 2026-10-07 03:10:41 -04:00
20260821T042058Z_b7aca4c0_prompt_io.md Preserve exact `piker` logger namespaces 2026-10-07 03:10:41 -04:00
20260821T042058Z_b7aca4c0_prompt_io.raw.md Preserve exact `piker` logger namespaces 2026-10-07 03:10:41 -04:00
20260826T222600Z_5f631e19_prompt_io.md Fix Binance USD-M websocket routing 2026-10-28 10:45:47 -04:00
20260826T222600Z_5f631e19_prompt_io.raw.md Fix Binance USD-M websocket routing 2026-10-28 10:45:47 -04:00
20260828T200352Z_dd676857_prompt_io.md Bump `xonsh` to 0.24.2 2026-10-07 03:10:41 -04:00
20260828T200352Z_dd676857_prompt_io.raw.md Bump `xonsh` to 0.24.2 2026-10-07 03:10:41 -04:00
20260829T175542Z_e09e306a_prompt_io.md Harden Binance USD-M feed startup 2026-10-28 10:45:47 -04:00
20260829T175542Z_e09e306a_prompt_io.raw.md Harden Binance USD-M feed startup 2026-10-28 10:45:47 -04:00
20260901T024235Z_e09e306a_prompt_io.md Fix reconnect startup in `_web_bs` 2026-10-28 10:45:47 -04:00
20260901T024235Z_e09e306a_prompt_io.raw.md Fix reconnect startup in `_web_bs` 2026-10-28 10:45:47 -04:00
20260901T230043Z_e91f41a6_prompt_io.md Bump `tractor` and `msgspec` for Python 3.13 2026-10-07 03:10:41 -04:00
20260901T230043Z_e91f41a6_prompt_io.raw.md Bump `tractor` and `msgspec` for Python 3.13 2026-10-07 03:10:41 -04:00
20260907T214000Z_9115d24_prompt_io.md Add neutral `.ai` workflow config 2026-09-07 19:07:00 -04:00
20260907T214000Z_9115d24_prompt_io.raw.md Add neutral `.ai` workflow config 2026-09-07 19:07:00 -04:00
20260908T043134Z_f148fbcc_prompt_io.md Move Piker skills to `.agents` discovery 2026-09-08 00:35:01 -04:00
20260908T043134Z_f148fbcc_prompt_io.raw.md Move Piker skills to `.agents` discovery 2026-09-08 00:35:01 -04:00
20261021T224421Z_507c75c6_piker_pin_prompt_io.md Select `piker_pin` and keep `polars` below 2.0 2026-10-21 19:16:14 -04:00
20261021T224421Z_507c75c6_piker_pin_prompt_io.raw.md Select `piker_pin` and keep `polars` below 2.0 2026-10-21 19:16:14 -04:00
20261022T212248Z_dc618229_ib_recovery_prompt_io.md Document bounded IB recovery and downstream replay 2026-10-23 11:36:29 -04:00
20261022T212248Z_dc618229_ib_recovery_prompt_io.raw.md Document bounded IB recovery and downstream replay 2026-10-23 11:36:29 -04:00
20261028T160846Z_7242dcb9_websocket_close.md .data: reconnect after websocket reader close errors 2026-10-28 12:48:06 -04:00
20261028T160846Z_7242dcb9_websocket_close.raw.md .data: reconnect after websocket reader close errors 2026-10-28 12:48:06 -04:00