Skip to content

fix(net): give the RP peer server the same stall budget as its client (#3899) - #4372

Merged
zackees merged 1 commit into
masterfrom
fix/rp-peer-server-stall-budget
Sep 12, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/rp-peer-server-stall-budget

Conversation

@zackees

@zackees zackees commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

--net-peer fails intermittently — about two runs in five, on master and on unrelated branches alike — with the RP's HTTP server taking complete headers and then none of a 4096-byte body:

POST /echo 4096-byte FNV-1a -> 408, received_bytes: 0
RP server stats: {'lastTimeoutWasStall': True, 'lastTimeoutElapsedMs': 2006,
                  'lastTimeoutBodyLength': 0, 'lastTimeoutExpectedBody': 4096,
                  'lastTimeoutHeadersComplete': True}

2006 ms against a 2000 ms budget. The peer missed by six milliseconds.

The asymmetry

constexpr uint32_t kRpPeerStallMs       = 2000;   // RP as server
constexpr uint32_t kRpHttpClientStallMs = 6000;   // RP as client
constexpr uint32_t kRpPeerMaxRequestMs  = 10000;  // absolute ceiling, both

The client side was raised 2000 → 6000 in #4231, and its comment records why: five requests at 2706, 2734, 2961, 3108 and 3586 ms completed correctly, each of which the old value would have failed, with the maximum sitting under the peer's own 5000 ms ceiling.

kRpPeerStallMs was deliberately left at 2000 so a dead connection would be reaped quickly. That reasoning treats the budget as a property of which side we are, when it is a property of the peer — the C6 services a request from its sketch main loop and blocks up to 5000 ms doing it, so a gap over 2000 ms is ordinary in either direction. The failure above is the same distribution observed from the other end.

Why 6000 and not 2500

6000 matches kRpHttpClientStallMs, which was derived independently from the peer's documented 5000 ms handler ceiling. Picking a value that merely clears the observed 2006 ms would be fitting the threshold to the symptom — and would leave the next 3586 ms request failing exactly as before.

Cost, stated

A genuinely dead peer now holds the single-client server for up to 6 s rather than 2 s before kRpPeerMaxRequestMs (10000, unchanged) reaps it. That is the trade the original comment was protecting, and it is real; the absolute ceiling still bounds it.

Measured

Attached pair, 10 reconnect cycles per run:

runs result
master 3 2 pass, 1 fail (cycle 7)
unrelated branch (#4343) 2 1 pass, 1 fail (cycle 5)
this branch 6 6 pass, 0 stalls

Six clean runs against a ~40% failure rate is roughly a 1-in-20 coincidence — strong but not proof for a fault of this shape. The six-millisecond miss is what carries it; the runs corroborate.

bash lint clean.

Found while running a regression control for #4343, where this failure initially looked like a regression in that PR until master reproduced it identically.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51

Summary by CodeRabbit

  • Bug Fixes
    • Improved RP2350W CYW43 peer-server reliability by allowing more time for stalled peer responses before timing out.
    • The existing 10-second maximum request limit remains in place for unresponsive connections.

`--net-peer` failed intermittently -- about two runs in five, on master
and on unrelated branches alike -- with the RP's HTTP server taking
complete headers and then none of a 4096-byte body:

    POST /echo 4096-byte FNV-1a -> 408, received_bytes: 0
    {'lastTimeoutWasStall': True, 'lastTimeoutElapsedMs': 2006,
     'lastTimeoutBodyLength': 0, 'lastTimeoutExpectedBody': 4096,
     'lastTimeoutHeadersComplete': True}

2006 ms against a 2000 ms budget: the peer missed by six milliseconds.

`kRpHttpClientStallMs` was raised 2000 -> 6000 in #4231 after five
requests at 2706-3586 ms were shown to complete correctly, all under the
peer's own 5000 ms handler ceiling. `kRpPeerStallMs` was left at 2000 so
a dead connection would be reaped quickly. That treats the budget as a
property of which side we are, when it is a property of the peer: the C6
services a request from its sketch main loop and blocks up to 5000 ms
doing it, so a gap over 2000 ms is ordinary in either direction. The
failure above is that same distribution seen from the other end.

Set to 6000 to match the client rather than to clear the observed
2006 ms -- the value comes from the peer's documented ceiling, not from
the symptom. A dead connection is still reaped: kRpPeerMaxRequestMs
(10000) is unchanged and is the absolute ceiling. The cost is that a
dead peer holds the single-client server for up to 6 s rather than 2 s
before that applies.

Measured on the attached pair, 10 reconnect cycles per run:

    before   master          2 pass / 1 fail
             unrelated branch 1 pass / 1 fail
    after    6 runs           6 pass, 0 stalls

Six clean runs against a ~40% failure rate is roughly a 1-in-20
coincidence, so this is strong but not proof for a fault of this shape;
the six-millisecond miss is what carries it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
@coderabbitai

coderabbitai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 82b90184-f3e1-403b-b127-5e691bbe671d

📥 Commits

Reviewing files that changed from the base of the PR and between 731fb6f and 2d90813.

📒 Files selected for processing (1)
  • examples/AutoResearch/AutoResearchNet.cpp

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The RP2350W CYW43 peer server now waits 6 seconds for peer activity instead of 2 seconds. The 10-second maximum request duration remains unchanged.

Changes

RP2350 peer timeout

Layer / File(s) Summary
Peer stall timeout adjustment
examples/AutoResearch/AutoResearchNet.cpp
The inactivity timeout increases from 2,000 ms to 6,000 ms. The 10,000 ms request ceiling remains unchanged.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 2d908

Slow RP peers receive sufficient time to send request bodies, while inactive requests remain bounded by the existing maximum duration.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: aligning the RP peer server stall budget with the client budget.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/rp-peer-server-stall-budget

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@zackees

zackees commented Sep 11, 2026

Copy link
Copy Markdown
Member Author

Evidence strengthened: 9/9 clean

I described the original result as "strong but not proof" — six clean runs against a ~40% failure rate is roughly a 1-in-20 coincidence, which is suggestive rather than conclusive for a fault whose defining property is intermittence. Three more runs:

runs 10-cycle passes stalls
master 3 2 1 (cycle 7)
unrelated branch (#4343) 2 1 1 (cycle 5)
this branch 9 9 0

Baseline: 2 failures in 5 runs. With the fix: 0 in 9. At that rate nine consecutive clean runs is about a 1-in-100 coincidence, so the result is now conclusive rather than suggestive, and the description's hedge can be read as superseded.

The mechanism remains what carries it — lastTimeoutElapsedMs: 2006 against a 2000 ms budget is a threshold sitting on top of the distribution it is meant to exclude, and 6000 was chosen to match kRpHttpClientStallMs (derived from the peer's documented 5000 ms handler ceiling) rather than to clear the observed 2006 ms. The run count corroborates it; it was never the argument.

Cost is unchanged and still real: a dead peer occupies the single-client server for up to 6 s rather than 2 s before kRpPeerMaxRequestMs (10000, unchanged) reaps it.

@zackees
zackees merged commit a5fb9e6 into master Sep 12, 2026
21 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Sep 12, 2026
@zackees
zackees deleted the fix/rp-peer-server-stall-budget branch November 5, 2026 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant