Repository navigation
Description
Summary
bash autoresearch rp2350w --net-peer completes six full peer cycles and then the RP2350W hangs inside wifiConnect on the seventh, long enough to trip the watchdog. Reproducible: two consecutive runs failed at cycle 7/10.
The good news first, because it is the larger part of the result: the peer network works. Each cycle runs wifiConnect → join the C6 SoftAP → startNetServer → HTTP RP2350W→ESP32-C6 → HTTP ESP32-C6→RP2350W → stopNet → serial ping, and cycles 1-6 complete all of it. Bidirectional HTTP between the two MCUs is proven on hardware.
Evidence
--- Peer network cycle 1/10 --- RP2350W serial RPC ping: PASS
...
--- Peer network cycle 6/10 --- RP2350W serial RPC ping: PASS
--- Peer network cycle 7/10 ---
Network peer autoresearch failed: No response with ID 112 within 4.79s
| Run | Failure |
|---|---|
| 1 | No response with ID 115 within 2.54s |
| 2 | No response with ID 112 within 4.79s |
Same cycle both times, different request IDs and timeouts — a deterministic failure point rather than flakiness.
It is a watchdog reset, not a dropped reply. Querying the board immediately after:
ping -> {"message":"pong","success":true,"uptimeMs":43785,
"lastResetCause":"WATCHDOG","lastResetWasWatchdog":true}
wifiStatus -> {"ip":"","apIp":"","status":"IDLE","success":true,"connected":false}
lastResetWasWatchdog: true with a ~44 s uptime means the device rebooted mid-cycle. The RPC did not time out because a reply was lost; it timed out because the device was resetting. That distinction matters — this is not the "request/reply loops drop replies" class documented in ci/autoresearch/rpc_bench.py, and it is not a --net-peer harness fault.
The failing call is the first RPC of the cycle: the loop prints cycle 7/10 and dies before wifiConnect returns (ci/autoresearch/net.py:536).
Interpretation
Something in the CYW43 connect path degrades across repeated connect/stopNet cycles and blocks on the seventh long enough to exceed the loop watchdog. Six is suspiciously consistent, which points at an exhaustible resource (socket/netif/DHCP state not fully released by stopNet, or an lwIP/CYW43 handle leak) rather than a timing race.
Worth noting the board recovers on its own — the watchdog reboots it and wifiStatus returns to IDLE. So this degrades a long soak rather than bricking the fixture.
Reproduce
bash autoresearch rp2350w --net-peer \
--upload-port /dev/ttyACM1 --peer-upload-port /dev/ttyACM0 --timeout 240Fixture
Confirmed Raspberry Pi Pico 2 W — 2E8A:F00F, status.platform "Raspberry Pi Pico 2 W (RP2350)", wifiStatus reporting real state rather than UNSUPPORTED. ESP32-C6 peer at 303A:1001, ser 8C:BF:EA:CF:87:B4. Linux (NixOS 6.18.48), fbuild 2.5.23.
Related: #3832 (gap 10 — network-carried JSON-RPC on RP2350W), #4097 (stabilize RP2350W peer cycles).
Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Sep 7, 2026
The connect/stop lifecycle is not the cause — narrowing this down
My original write-up guessed that "something in the CYW43 connect path degrades across repeated connect/
stopNetcycles". That is wrong, and it is worth recording so nobody spends time there.Drove
wifiConnect+stopNetdirectly over serial RPC, 12 consecutive cycles, no AP present:Twelve cycles, stable to the hundredth of a second, well past the 7 where
--net-peerdies. No drift, no watchdog reset, and the board had ~90 minutes of uptime beforehand withlastResetCause: SOFTWARE.So
WiFi.mode(WIFI_STA)→beginNoBlock→WiFi.end()repeated is fine on its own. Whatever exhausts itself is in one of the steps the bare loop skips.What that leaves
The full peer cycle (
ci/autoresearch/net.py:534) does more than connect/stop:wifiConnectwifiStatusuntil it actually associates with the C6 SoftAP and gets a DHCP leasestartNetServer— opens a listening HTTP socketrunNetClientTestRP→C6 — outbound HTTPrunNetClientTestC6→RP — inbound HTTP against the server from 3stopNetThe bare loop exercises only 1 and 6. So the candidates are the association/DHCP path or, more likely, socket/lwIP resources from the HTTP server and client not being fully released by
stopNet— a listener or PCB leaking once per cycle until the pool runs dry on the seventh.That also fits the failure shape better than a driver-state theory: it is the first call of cycle 7 that hangs long enough to trip the watchdog, consistent with an allocation blocking rather than a link failing.
Suggested next probe
Same style of targeted loop, but adding
startNetServer(and ideally onerunNetClientTest) to each iteration, with the C6 SoftAP up. If it dies at 7 with the server included but not without, the leak is in the server/socket teardown rather than in CYW43.Environment unchanged: RP2350W
2E8A:F00Fon /dev/ttyACM1, fbuild 2.5.23, NixOS.Generated with Claude Code
https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
zackees commentedon Sep 7, 2026
Isolated to the HTTP transfer — and it is pathologically slow
Continued the incremental probes, adding one step of the peer cycle at a time. Two more branches eliminated, and the remaining one looks bad.
Association + DHCP + server socket are clean. Ten cycles with the C6 SoftAP actually up and the RP genuinely associated:
Flat through cycle 7 and past it. So the socket-teardown theory I suggested last time is also wrong —
startNetServer/stopNetdo not leak.That leaves
runNetClientTest, and it takes 26.57 s.For one HTTP request to
192.168.4.1:80over a local SoftAP link. Every other operation in the cycle is sub-second:wifiConnectstartNetServerrunNetClientTeststopNetIt succeeds (
ok=True), so this is not a retry-until-failure path — the transfer genuinely takes that long.Why that matters for the cycle-7 hang
net.pycallsrunNetClientTestwithmax_wait=30.0, and the peer cycle makes two of them (RP→C6 and C6→RP). At 26.57 s each, the run is already within ~3.4 s of its own timeout on a healthy first cycle. Any per-cycle degradation, or the second direction being slower than the first, crosses it.That reframes the bug: rather than a resource leaking to exhaustion at exactly seven, this looks like an operation that is marginal from cycle 1 and eventually loses a race it was always close to. It also fits the watchdog reset — a blocking call of that length is the same hazard #3956 records for
pollOtaArtifactUpdate("a full firmware download can exceed the configured 5000 ms timeout and reset the board mid-upgrade").Suggested direction
The question is no longer "what leaks" but "why does a single local HTTP GET take 26.5 s". Candidates: a DNS or connect timeout being burned before falling through, Nagle/delayed-ACK interaction on the CYW43 link, or a fixed receive timeout the client waits out rather than closing on content-length.
Whoever picks this up should time the phases inside
runNetClientTeston device — connect, send, first byte, complete — since a 26 s wall almost always turns out to be one fixed timeout rather than slow throughput.Both probes ran with the boards healthy throughout: no watchdog resets, RP associating at
192.168.4.2every cycle, C6 SoftAP steady at192.168.4.1:80.Generated with Claude Code
https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
zackees commentedon Sep 7, 2026
Correction: that 26.57 s is 12 requests, not one
I described the previous measurement as "one HTTP request to
192.168.4.1:80". That is wrong, and it overstates the anomaly.runNetClientTest(examples/AutoResearch/AutoResearchNet.cpp:1041) issues 12 HTTP requests per call:/ping,/status,/leds,/rpc/discover,/rpc/ping,/rpc/status,/rpc/unknown/rpcSo 26.57 s is roughly 2.2 s per request, not a 26 s single-request wall. That is slow for a local SoftAP link but a lot more ordinary than what I implied, and it does not point at one fixed timeout the way I suggested. Please disregard the "time the phases inside the request" recommendation as stated — it was premised on a single request.
It also explains why no watchdog fires during the call: the loop feeds it between requests (
FastLED.watchdog().feed()after each), so a long total duration is expected and handled by design.What still stands
The budget pressure is real, and it is the part worth keeping:
net.pycallsrunNetClientTestwithmax_wait=30.0That is ~3.4 s of headroom against its own timeout, from cycle 1, before any degradation. So the earlier conclusion holds even though my per-request figure was wrong: this looks like an operation that is marginal from the start rather than a resource that exhausts itself at exactly seven.
Revised suggestion
Rather than hunting a single fixed timeout, the useful questions are:
max_wait=30.0simply too tight for a 12-request suite over CYW43, in which case the fix may be the budget rather than the transport?Timing per-request inside the loop would answer the first cheaply, since the call already iterates and could log each one.
Boards remain healthy; no watchdog resets across any of these probes.
Generated with Claude Code
https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
zackees commentedon Sep 7, 2026
Root cause found: the drain loop waits out a fixed deadline
runRpHttpRequestTest(examples/AutoResearch/AutoResearchNet.cpp:855) reads each response like this:It exits on the 2 s deadline or on the peer closing. With HTTP keep-alive the server does not close, so
client.connected()stays true and the loop burns the remaining deadline after the body has already arrived.The arithmetic matches exactly: 12 requests per
runNetClientTestat ~2.2 s each = ~26.4 s, against the 26.57 s measured. That is the whole 26.5 s, and it is idle waiting rather than transfer time.Which completes the chain for this issue: 26.5 s per call → two calls per cycle → a 30 s
max_waitwith ~3.4 s of headroom on a healthy first cycle → eventually loses a race it was always close to.This also corrects my previous suggestion. I wrote that "the fix may be the budget rather than the transport". That was wrong — raising
max_waitwould have masked a transport that idles away ~90% of its time.An attempted fix that I am not proposing
I tried stopping on peer idle (150 ms after the last byte) plus a full-buffer break, keeping the 2 s deadline as the hard ceiling. Measured on hardware, 8 cycles:
ok=Trueok=Falseon 7 of 8Roughly 2.8x faster and incorrect: only cycle 3 passed all 12 sub-tests. Breaking on idle truncates responses before the expected fragment arrives, so the content assertions fail intermittently. I reverted it rather than trade correctness for speed, and the tree is unchanged.
What a real fix needs
Stop on completeness, not on silence:
Content-Lengthfrom the response headers and read exactly that many body bytes; orThe 256-byte
responsebuffer complicates it — with a body longer than the buffer, the loop must keep draining to reach completion while only recording the first 256 bytes, otherwise the socket is left mid-response.That is worth doing: it should cut
runNetClientTestfrom ~26.5 s to a few seconds and remove the budget pressure at its source rather than papering over it. But it wants a proper test rather than an unattended guess, which is why I am reporting it instead of pushing a patch.Both boards remained healthy throughout; the RP2350W is back on the unmodified build.
Generated with Claude Code
https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
zackees commentedon Sep 7, 2026
Baseline measured: 9/9, and it rules out both of my fix attempts
Ran the same 9-cycle probe against the unmodified build:
9/9 passing, spread under 0.25 s. Slow, but completely reliable and near-deterministic — which follows from the mechanism: waiting out a fixed 2 s per request is insensitive to when data actually arrives.
Against that, both attempts to speed it up were regressions:
Both reverted; PR #4182 closed. The 12.3 s spread on the second one is the diagnostic: if
Content-Lengthwere present and parsed on every response, timings would cluster. They do not, so some responses on this path likely use chunked encoding or a header form my parse missed, and those still fall through to the 2 s deadline. A correct fix must handle the chunked terminator too.What this settles for the cycle-7 hang
At 26.8 s the content assertions pass every single time, across nine consecutive cycles including cycle 7. So the
--net-peerfailure is not these HTTP checks failing, and not the RP2350W degrading over cycles — the board is fine at cycle 9 of a direct probe.That leaves the timing budget itself.
net.pyallowsmax_wait=30.0per call and makes two calls per cycle:So the most likely story is that the second direction, or the pair together, crosses a limit that the first direction alone never does. Someone with the fixture should time the C6 -> RP call specifically; that is the one measurement still missing.
Where the real fix lies
Not in the budget — 26.8 s of a 30 s allowance spent almost entirely idle is the defect, and raising
max_waitwould hide it. But it needs completion detection that handles bothContent-Lengthand chunked responses, verified to hold 9/9. That is a bigger piece of work than it looked, and the two shortcuts both failed.The header/body separation from #4182 is independently correct —
response[256]currently holds headers and body, so long headers can push the asserted fragment out of the window — and could be landed on its own.Boards remained healthy throughout; RP2350W is back on the unmodified build, tree clean.
Generated with Claude Code
https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
zackees commentedon Sep 7, 2026
The missing measurement: the two directions differ by ~10x
Timed both directions of the peer cycle against the same link, 5 cycles, unmodified build:
Same 12-request suite, same SoftAP link, both returning 12/12. The C6 client does in ~2.7 s what the RP client takes ~27 s to do.
That is the cleanest possible confirmation that the RP-side client drain loop is the defect — not the network, not the CYW43 link, and not the RP2350W in general. When the RP is the server, the same 12 requests complete in under 3 s.
It also disposes of a theory worth naming: the reverse direction is not the hidden cost I suggested last time. It is nearly free.
Total per cycle sits right on the limit
The pair totals are the other half of the story:
net.pyallowsmax_wait=30.0per call, and each individual call does fit — 27 s and 2.8 s both clear it. But the cycle's HTTP work is consuming ~30 s of wall clock on its own, with essentially all of it spent idling inside the RP client. Cycle 4 crossed 31 s purely from the reverse call drifting to 4.5 s.So the margin is not comfortable anywhere, and almost all of it is recoverable: ~24 s of the 27 s forward call is the fixed 2 s-per-request wait, not transfer.
A new failure mode at cycle 5
The reverse call failed fast — 0.23 s, no sub-test results at all — meaning the C6 could not reach the RP2350W's server, rather than any request failing. The forward direction in that same cycle was fine (26.57 s, ok=True).
That is a different shape from everything else here and may be the actual cycle-7 mechanism: not a slow degradation, but the RP's listening socket becoming unavailable after several cycles while the RP itself stays healthy. Worth a focused look at
startNetServer/stopNetsocket reuse across cycles — noting my earlier probe of those two RPCs in isolation ran 10 clean cycles, so it likely needs the HTTP traffic to reproduce.Standing summary for this issue
wifiConnect/stopNetalone: 12 cycles cleanstartNetServer: 10 cycles cleanGenerated with Claude Code
https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
zackees commentedon Sep 7, 2026
Retracting the "listening socket" lead
I suggested the fast reverse-direction failure seen once at cycle 5 "may be the actual cycle-7 mechanism". Accumulated data says no — it is sporadic, not a pattern, and not tied to a cycle number.
Reverse direction (ESP32-C6 as client fetching from the RP2350W), across three runs:
One failure in ten cycles, at cycle 5 rather than 7, with the other nine at 2.6 - 4.5 s and 12/12. That is a ~10% sporadic event, not the deterministic cycle-7 mechanism I implied. Anyone picking this up should not spend time on socket-reuse in
startNetServer/stopNeton the strength of my earlier comment.What is actually established for this issue
client.connected()does not go false promptly despiteConnection: close; 12 requests x ~2.2 s = the 26.5 s measured, almost all idlestartNetServer(10 clean cycles), a single fixed per-request timeout, and reverse-direction costThe remaining question is unchanged and narrow: why does the RP-side HTTP client spend ~2 s per request idle when the C6 client does the same 12 requests in under 3 s? A correct fix needs completion detection that handles both
Content-Lengthand chunked responses, verified to hold 9/9.Further probing here is currently limited by host memory pressure on this bench rather than by the boards, which have stayed healthy throughout.
Generated with Claude Code
https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
fix(autoresearch): a truncated HTTP body is a failure, not a pass (#4173
zackees commentedon Sep 7, 2026
Resolved by #4196 — 10/10 cycles, including cycle 7
Ran the full bidirectional peer cycle directly over RPC (
wifiConnect→ associate →startNetServer→ HTTP RP→C6 → HTTP C6→RP →stopNet), which exercises the same firmware path as--net-peerwithout the harness:Cycle 7 — the one that reproducibly killed this before, twice — is unremarkable here at 11.16 s.
Why this closes the loop on the diagnosis
The mechanism was the timing budget, exactly as the measurements suggested.
net.pyallowsmax_wait=30.0per call and makes two per cycle; before the fix the pair consumed 29.5–31.3 s of wall clock, with cycle 4 measured at 31.27 s — already over. Almost all of it was the RP client idling out a fixed 2 s deadline per request, 12 requests per call.With the drain loop reading to completion, the same work takes a third of the time and the budget is no longer close.
Caveats, stated plainly
bash autoresearch --net-peer. The firmware path is the same; the harness path still needs fbuild-daemon leaks the serial fd, breaking the next run; 'daemon stop' cannot see it fbuild#1426 (daemon retains the serial fd after deploy) before a full end-to-end run is possible here.Recommend this issue stays open until a real
--net-peerrun passes, but the mechanism is identified and the fix is validated on the hardware path.Generated with Claude Code
https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
fix(autoresearch): read RP HTTP responses to completion, not to a dea…
zackees commentedon Sep 7, 2026
Confirmed through the real harness — cycle 7 passes
The previous result was via direct RPC, which I flagged as a proxy. Ran the actual command that originally failed:
8 consecutive cycles passed, zero failures. Cycle 7 — which killed this run twice before with
No response with ID 115andID 112, each time a watchdog reset — passes without comment.The run stopped during cycle 9 when my session's supervisor killed the process. That is a host-side interruption on my end, not a test failure: there are no
failed/error/No responselines anywhere in the log, and both boards stayed enumerated and healthy.Status
This is the end-to-end confirmation I said this issue should wait for. With #4196:
The mechanism was the timing budget:
max_wait=30.0per call, two calls per cycle, and the pair was already consuming 29.5–31.3 s — cycle 4 measured 31.27 s, over budget — almost all of it the RP client idling out a fixed 2 s deadline across 12 requests per call.I would still like to see a clean 10/10 through the harness before closing, since mine stopped at 9 for reasons unrelated to the firmware. But cycle 7 passing in the real harness is the specific evidence that was missing.
Generated with Claude Code
https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
zackees commentedon Sep 7, 2026
Closing on a completed 10/10 run. I said earlier in this thread I would not close on partial evidence, so here is the full run.
bash autoresearch rp2350w --net-peer --peer-environment esp32c6 --timeout 1500, on master with #4196 merged:Exit 0. Cycle 7 — where the original hang tripped the watchdog — passes, and the run continues cleanly through 10 with both boards still answering serial RPC at the end. Neither board wedged.
Evidence chain for the fix (#4196): the root cause was
AutoResearchNet.cppdraining the HTTP response against a deadline rather than reading to completion, so a status line split across TCP segments left the connection mid-response and the next cycle inherited the desync. Replaced with a completion-based read —read_line()for the status line and headers, then exactlyContent-Lengthbody bytes. Two earlier attempts were rejected by measurement against a 9/9 baseline before this one (150ms idle-stop scored 1/8; Content-Length-only scored 6/9), and #4182 was closed as a result.One trap worth recording for whoever runs this next. My first attempt today failed at cycle 2 with:
That reads exactly like a device hang, and I nearly filed it as one. It is not.
--timeoutdefaults to 30s and is documented as the monitor-phase timeout, but--net-peeruses it as a whole-run deadline across all ten cycles (deadline = time.monotonic() + timeoutinci/autoresearch/net.py). Cycle 1 plus the two RPC connects consume it, and every later RPC gets whatever milliseconds remain. A 20ms RPC timeout is indistinguishable from an unresponsive board at a glance.--net-peerneeds a generous--timeout(I used 1500s). It would be worth either giving the peer modes their own default or renaming the flag, since the current behaviour turns an operator omission into a convincing false hardware failure. Happy to file that separately if useful.fix(autoresearch): time the RP HTTP server on stall, not total elapsed
fix(autoresearch): three RP SPI harness bugs that reported host failu…