Skip to content

fix(node): serve path converts faults into silent empty successes (#1833) - #1837

Merged
thiras merged 2 commits into
mainfrom
fix/serve-path-faults-silent-empty-successes
Aug 26, 2026
Merged

thiras merged 2 commits into
mainfrom
fix/serve-path-faults-silent-empty-successes

Conversation

@thiras

@thiras thiras commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Closes #1833.

Three sites on the cdn/client/v1 serve path turned a fault into something that looked like a successful empty result. They shared one root cause and lived in two files, so they were worth one pass.

1. CoherentFrameProducer::new (serve_encoder.rs)

align_range errors were flattened to ChunkRanges::empty(), so an unalignable request made the encoder emit zero bytes and the serve loop write StreamEnd for a non-empty request — telling the client a non-empty range was delivered in full, unlogged and unmetered.

new now returns anyhow::Result<Self> and propagates the alignment error. The legitimate end == offset empty request stays separate and never errors.

2. AwaitingDataReader::read_at (serve_encoder.rs)

The same map_or_else to ChunkRanges::empty() surfaced an alignment bug as the misleading "every covering pull ended" error, blaming the pull leg. It now maps the align error to an io::Error and propagates it.

3. dispatch sink (dispatch.rs)

Every error out of serve_stream — node-side bug and ordinary client disconnect alike — landed at debug!, below the project's default RUST_LOG=info, which is what made 1 and 2 invisible.

Added a ClientDisconnect marker (peer hang-ups: write I/O, proof read timeout, request read) and a ClientPaymentFault marker (buyer underpayment bails), and split the sink so a node-side fault logs at error! while a peer disconnect or client payment fault stays at debug!.

The framing half of this problem was already handled by #1835 (FrameAccountingFault + decdn_serve_frame_accounting_fault_total); this change sits alongside it rather than duplicating it.

Verification

  • cargo build --workspace, cargo clippy --workspace, cargo fmt -- --check clean.
  • cargo nextest run -p decdn-node — 1044 tests pass, including a new test an_unalignable_request_errors_at_construction_not_as_an_empty_range.
  • cargo nextest run -p decdn-e2e — 15 tests pass.

)

Three sites on the cdn/client/v1 serve path turned a fault into something that
looked like a successful empty result.

CoherentFrameProducer::new now returns a Result and propagates an unalignable
request (an offset past the blob end, or an end that overflows or exceeds the
blob size) instead of flattening it to an empty range, which made the encoder
emit zero bytes and the serve loop write StreamEnd for a non-empty request.
The legitimate end == offset empty request stays separate and never errors.

AwaitingDataReader::read_at maps an alignment error to an io::Error and
propagates it instead of substituting an empty range, which surfaced as a
misleading 'every covering pull ended' that blamed the pull leg for an
alignment bug.

The dispatch sink logged every serve_stream error at debug!, below the
default RUST_LOG=info, so node-side faults were invisible. Add a
ClientDisconnect marker for peer hang-ups (write I/O, proof read timeout,
request read) and a ClientPaymentFault marker for buyer underpayment bails,
and split the sink so a node-side fault logs at error! while a peer
disconnect or client payment fault stays at debug!.
Copilot AI lite review requested due to automatic review settings August 26, 2026 10:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@thiras
thiras requested a lite review from Copilot August 26, 2026 10:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 82.01% (was 82.00%, ● 0.00%) — 68430/83445 lines

File Coverage Lines Δ
crates/node/src/handlers/client/delivery.rs 92.62% 339/366 ▼ 1.02%
crates/node/src/handlers/client/dispatch.rs 86.18% 449/521 ▲ +0.19%
crates/node/src/handlers/client/mod.rs 92.78% 1568/1690 ▼ 0.09%
crates/node/src/handlers/client/serve_encoder.rs 88.75% 426/480 ▼ 0.09%
crates/node/src/handlers/client/serve_leg.rs 81.91% 154/188 ▼ 2.06%
crates/node/src/handlers/client/voucher.rs 93.21% 494/530 ▼ 0.34%
crates/node/src/handlers/client/wire.rs 95.70% 401/419 ▼ 0.02%
crates/node/src/metrics.rs 94.51% 860/910 ● 0.00%
History
Commit Total Δ vs base
b0917a3 82.01% ▲ +0.01%
b22fd8c (HEAD) 82.01% ● 0.00%

…view)

The dispatch sink split lands, but the marking around it was mis-tuned in
both directions and one class of node fault was still silenced.

- `BufferedProofReader::read` marks its peer arms — a reset stream, a
  hang-up mid-frame, a malformed or undecodable frame, a non-proof
  message. Those are the dominant client-abandon shapes and reached
  `error!` unmarked. Its two bounds checks stay unmarked: node invariants.
- `VerifyStop::Bail` carries an `anyhow::Error` rather than a `String`, so
  the two client-attributable stops mark themselves and the defensive
  `RetrySignal` bail beside them does not. The `MAX_PROOFS_PER_CHUNK`
  bails mark as `ClientPaymentFault`.
- The wire writes discriminate: `FrameError::TooLarge` and
  `WriteError::{ClosedStream, ZeroRttRejected}` are this node's own bugs
  and reach `error!`; the rest are the peer.
- `serve_leg` refuses an offset at or past the blob end instead of letting
  the clamp fold it into the legitimate empty request.
- `ClientDisconnect` becomes `PeerFault`: it marks read timeouts and
  malformed requests too, which "client disconnected" misnamed.
- One `log_stream_end` helper replaces the duplicated sink predicate,
  logs `{e:#}`, and bumps `decdn_serve_stream_node_fault_total` so the
  class is alertable rather than only greppable.
- The request-read marker rides as context so the inner chain survives.

Tests pin the classifier: marker survival under stacked context, oversized
frame vs write I/O, write-after-close vs peer stop, and a malformed proof
frame. `read`'s frame half splits into `take_buffered` to make the last one
reachable without a stream.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@thiras
thiras merged commit effd55f into main Aug 26, 2026
25 checks passed
@thiras
thiras deleted the fix/serve-path-faults-silent-empty-successes branch August 26, 2026 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

serve path converts faults into silent empty successes (align_range, read_at, dispatch log sink)

3 participants