Skip to content

flaky(test): node_origin_pull sliver-voucher test reads frames cancel-unsafely under timeout (postcard decode error) #2306

Closed

Description

@thiras

Symptom

node_origin_pull::window_pull_through_sliver_voucher_leaves_the_rest_owed fails intermittently under CPU contention:

Error: expected the stream to run to StreamEnd, got Err(leaf decode: postcard decode error: Serde Deserialization Error

It fails during the leaf's "pay whenever B goes quiet" loop, through read_client (crates/node/tests/node_origin_pull.rs ~L6984).

Observed rate (Linux x86_64, 16 cores, main @ b37bbc4a + an unrelated cache-crate change)

Setup Failures
Full -p decdn-node suite, --retries 0, run concurrently with a second full suite (heavy contention) 3/8
-E 'binary(node_origin_pull)' alone, --retries 0 0/25

This only shows up when the machine is heavily loaded. The test binary never builds an HTTP or S3 origin, so the change on the branch where this was seen cannot reach it.

Root cause: a cancel-unsafe frame read inside timeout

The loop is:

match tokio::time::timeout(Duration::from_millis(500), read_client(&mut leaf.recv)).await {
    ...
    Err(_quiet) => { /* pay, then loop and read again */ }

read_client → decdn_protocol::read_frame reads the varint length and then read_exacts the payload (crates/protocol/src/framing.rs:203). The read is not cancel-safe. Under load, a ChunkData frame can arrive across the 500 ms boundary. The timeout then drops the future after it has consumed the length prefix and part of the payload. The bytes it read are lost. The next iteration starts reading in the middle of the frame and decodes garbage, which gives the postcard error.

The decode error is a test artifact, not a wire desync from the node.

Fix

Keep the in-flight read alive across "quiet" ticks instead of cancelling it. Either pin one read_client future and select! it against a sleep, or read frames on a dedicated task that feeds an mpsc channel and apply the timeout to rx.recv(), which is cancel-safe.

Same hazard elsewhere (audit candidates)

These test sites wrap read_frame/read_client in timeout inside a loop. Any of them that keeps reading the same stream after a timeout has the same bug:

  • crates/node/tests/node_origin_pull.rs: window_pull_through_sliver_vouchers_exhaust_the_proof_budget (~L10371)
  • crates/node/tests/client_loopback.rs: read_exact_chunks, assert_parked_awaiting_voucher, expect_reject, pay_range_to_end, read_unpaid_opening, pay_and_read_to_end, read_voucher_reject, sliver_vouchers_exhaust_the_per_chunk_proof_budget
  • crates/e2e/tests/pool_floor_ceiling_aggregate.rs: open_and_hold (~L561)

The production sites (handlers/client/mod.rs:2508, handlers/dht.rs:752, handlers/probe.rs:785) and crates/e2e/src/client.rs:511 stop reading or reset the stream after a timeout, so they are not affected.

A shared cancel-safe helper (for example, a FrameReader that owns the partial buffer) would remove the whole class.

Activity

  1. added
    kind:bug
    prio:medium
    rust
    kind:test
    area:node
    on Oct 5, 2026
  2. self-assigned this
    on Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:nodekind:bugkind:testprio:mediumrust

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions