Skip to content

iroh/noq 1.4 closes client pulls with "too many gaps in stream buffer"; hold at 1.3 #2585

Open

Description

@thiras

Summary

iroh/noq 1.4.0 kills client pulls mid-transfer. 131f6684 holds the iroh family at 1.3.0 in Cargo.lock (the baseline ADR 000 records). This issue tracks lifting that hold.

The cause is a known upstream regression: quinn-rs/quinn#2809, fixed in quinn by quinn-rs/quinn#2814 (quinn-proto 0.11.18). noq 1.4.0 has the cap but not the fix. n0-computer/noq#828 ports the fix and is open.

What breaks

noq-proto 1.4.0 adds a per-stream cap on buffered chunks (src/connection/assembler.rs):

const MAX_CHUNKS: usize = 1024;
const COMPACT_THRESHOLD: usize = 2 * MAX_CHUNKS;
...
if over_allocation > threshold || self.data.len() > COMPACT_THRESHOLD {
    self.defragment();
    if self.data.len() > MAX_CHUNKS {
        return Err(TooManyChunks);
    }
}

recv.rs maps it to TransportError::INTERNAL_ERROR, so the receiver (our client) closes the whole connection:

ConnectionClosed(ConnectionClose { error_code: INTERNAL_ERROR, frame_type: None, reason: b"too many gaps in stream buffer" })

1.3.0 has no such cap.

The cap counts retained buffers, not gaps. insert passes the whole packet payload length as allocation_size. A bulk-transfer packet carries one large STREAM frame, so the frame fills at least 83% of its allocation. try_mark_defragment then marks the buffer as defragmented, and defragment() never merges defragmented buffers. Each unread packet stays a separate buffer, even when the data is contiguous. About 2049 unread packets (~2.4 MiB at ~1200 B per frame) trip the cap with zero gaps.

Proof: an Assembler unit test on a copy of noq-proto 1.4.0.

  • In-order, gap-free 1200 B frames in 1220 B packets, with no reads: TooManyChunks at frame 2048, 2,458,800 bytes buffered.
  • The same frames, read after each insert: 100,000 frames, no error.

The trigger is a reader that falls ~2.4 MiB behind the sender. The cap is fixed and does not scale with the receive window. Our client advertises CLIENT_STREAM_RECEIVE_WINDOW = 64 MiB / CLIENT_RECEIVE_WINDOW = 128 MiB (crates/client/src/endpoint.rs), sized to the node's credit window (ADR 003 § Credit window). The node can legitimately run far more than 2.4 MiB ahead of the client's reads. The client reads frame by frame and does work between frames (bao verification, store writes, vouchers), so a short pause on a fast link is enough.

Effect on us

  • The paid leg dies with connection lost about 12 MiB into a ~20 MiB pull.
  • The node has served ~2 MiB on credit past the paid frontier (paid_wire_bytes=10485760, client landed=12533760). This matches a ~2.4 MiB unread backlog.
  • The client resumes from what landed, so that credit-window span is never paid.
  • anvil e2e (journeys) fails on the under-pay checks: cli_fetch_topup::fetch_of_blob_far_exceeding_deposit_settles_whole_wire_cost_once (3/3 retries, settled 18095 < wire floor 20083) and cli_bundle_pull_range_dedup::cli_bundle_pull_self_heals_a_lying_recipient_hint.

Bisection: the pre-bump lock passes; the pre-bump lock plus cargo update -p iroh (iroh, iroh-base, iroh-dns, iroh-relay, noq, noq-proto, noq-udp → 1.4.0) fails deterministically. tokio 1.54 alone does not trigger it.

The debug logs also show ~20 iroh multipath path::abandoned events (RemoteAbandoned { error_code: 62 }) in the second before the close. Reordering is not necessary to trip the cap, so these are probably not the cause.

Cost of the hold

noq-proto 1.3.0 predates the quinn fixes for RUSTSEC-2026-0185: a peer that sends small gapped STREAM or CRYPTO frames can make the assembler buffer an unbounded number of chunks. This applies to nodes (any client is a peer) and to clients (any node is a peer). cargo audit does not flag it because the crate is renamed. The hold trades broken pulls for this exposure.

Diagnose

cargo build -p decdn-node -p decdn-cli
DECDN_NODE_LOG='warn,noq_proto=debug,iroh=debug' \
  cargo nextest run -p decdn-e2e --features anvil-e2e \
  -E 'test(fetch_of_blob_far_exceeding_deposit_settles_whole_wire_cost_once)' --retries 0 --no-capture
# grep the output for `conn::closed`

To do

Activity

  1. added
    kind:bug
    dependencies
    on Oct 21, 2026
  2. self-assigned this
    on Oct 21, 2026
  3. removed their assignment
    on Oct 21, 2026
  4. added
    status:blocked
    area:client
    on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clientdependencieskind:bugstatus:blocked

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    • Status
      Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions