gabriel / muse public
fix BREAKING transport task/wire-staleness-fix #1 / 1
AI Agent gabriel · 155 days ago · Apr 22, 2026 · Diff

fix(transport): force fresh H2 connection in push_stream to prevent BAD_RECORD_MAC

The push operation sequence is: refs → negotiate → presign_objects → [R2 PUTs] → push_stream. Presigned R2 PUTs use a separate httpx client and can take 30+ seconds. During that window the shared _wire_client H2 connection to Cloudflare goes idle; CF drops it. Reusing the stale connection desynchronises TLS state and triggers SSLV3_ALERT_BAD_RECORD_MAC, causing push/stream to never reach the origin server.

Fix: _push_stream_httpx now closes and nulls _wire_client before the streaming POST, guaranteeing a fresh H2 connection regardless of presign PUT duration.

T24 tests verify: stale client is closed before push, and None client creates fresh without crashing.

Also updates musewire-performance.md to reflect all completed work (server request.stream(), httpx paths for all endpoints, shared client) and documents the Cloudflare connection staleness root cause.

sha256:b5a2e00cce7a04b711f745cf052a14e490f0d5078e543d09a5ac05ef7d23b088 sha
+11 ~21 −6 symbols
sha256:301c41fb025bc4466dfa72da550e507b5b898cec767c447b0dedb3d005df85ed snapshot
+11
symbols added
~21
symbols modified
−6
symbols removed
0
dead code introduced
Semantic Changes 38 symbols
~ docs/protocol/musewire-performance.md .md 8 symbols added, 6 symbols removed, 19 symbols modified
− table@L249 section table@L249 L249–259
− fetch_stream endpoint (line 463) section fetch_stream endpoint (line 463) L212–223
− presign_objects endpoint (line 277) section presign_objects endpoint (line 277) L223–228
− push_stream endpoint (line 212) section push_stream endpoint (line 212) L177–212
− code@L44 variable variable code@L44 L44–63
− table@L268 section table@L268 L268–278
+ table@L198 section table@L198 L198–208
+ fetch_stream endpoint section fetch_stream endpoint L169–177
+ presign_objects endpoint section presign_objects endpoint L177–182
+ push_stream endpoint section push_stream endpoint L157–169
+ code@L49 variable variable code@L49 L49–68
+ Known issue — Cloudflare connection staleness (RESOLVED in client) section Known issue — Cloudflare connection staleness (RESOLVED in client) L213–238
+ code@L219 variable variable code@L219 L219–222
+ table@L240 section table@L240 L240–250
~ py)
~ py)
~ tests/test_wire_h2_strict.py .py 3 symbols added
+ TestT24PushStreamFreshConnection class class TestT24PushStreamFreshConnection L484–568
+ test_no_existing_client_still_works method method test_no_existing_client_still_works L534–568
+ test_stale_wire_client_is_closed_before_push method method test_stale_wire_client_is_closed_before_push L494–532
← Older Oldest on task/wire-staleness-fix
All commits
Newer → Latest on task/wire-staleness-fix

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:b5a2e00cce7a04b711f745cf052a14e490f0d5078e543d09a5ac05ef7d23b088 --body "your comment"