Skip to content

Check receipt timeouts after the job loop - #102

Open
jamiecounsell wants to merge 1 commit into
attermann:masterfrom
zerokelvin-dev:receipt-timeout-after-jobs
Open

jamiecounsell wants to merge 1 commit into
attermann:masterfrom
zerokelvin-dev:receipt-timeout-after-jobs

Conversation

@jamiecounsell

@jamiecounsell jamiecounsell commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Receipt timeouts were checked inside the job loop. A timeout callback that sends (e.g. a retry) never returned, because Transport::outbound() waits for the job loop to finish.

Solution

Move the receipt check after the job loop, after _jobs_running is cleared, next to the resource watchdogs (which were moved there for the same reason). It still runs only on a pass where the jobs ran.

Compatibility

  • No change to wire behavior vs. the Python reference implementation (the reference runs this check in its job loop too, but starts each timeout callback on its own thread (Packet.py L542-L545), so a send from it doesn't block the loop. Running the callback after the loop is the closest a single thread gets.)
  • Any divergence from the reference is behind an RNS_* preprocessor guard (off by default) (none)
  • No breaking public API change
  • No board- or variant-specific code; any platform-specific code is unavoidable, isolated, and explained below

Testing

test_transport gains test_receipt_timeout_callback_can_send: a timeout handler sends a retry, and Reticulum::loop() must return. It runs the loop on a worker thread with a 10 s deadline, so without this change it fails with a message instead of hanging the suite (checked: it fails on master and passes with this change).

Tested with:

  • native (CMake): Linux aarch64, GCC 14.2, C++17. All 19 test suites pass.
  • ESP32 (board: ThinkNode M9, ESP32-S3)
  • nRF52: not tested on hardware; CI builds wiscore_rak4631.
  • Interop with Python RNS (test_interop/): not applicable, no wire change

Not tested on macOS (no machine). Left CI to build the embedded targets.

@attermann

Copy link
Copy Markdown
Owner

Thanks for tracking this down. A timeout callback that sends and then blocks on outbound() is a real problem, and moving the receipt check after the job loop looks like the right fix.

Two things before this can go further:

  1. The contribution policy asks for one logical concern per PR (section 5.2). Because this is stacked on Port the link watchdog #101, the diff also contains the Link watchdog, keepalive handling, link-proof validation and the resource-tick move, none of which the description mentions. Could you reduce this PR to just the receipt-timeout change, and let the rest be reviewed in Port the link watchdog #101?
  2. This branch starts before the 0.5.1 tag and is behind master. Please rebase once Port the link watchdog #101 is sorted, so the Transport::jobs() changes line up with the current code.

If the link watchdog changes stay in #101, it would also help to say how they were checked against Python RNS (keepalive and stale-link behaviour over LoRa or test_interop/), since they change what the node sends on the wire.

Transport::jobs() checked receipt timeouts inside its job loop, while
_jobs_running was set. A timeout callback that sends, such as a retry,
reaches Transport::outbound(), which waits for _jobs_running to clear.
The loop never finished, so the node hung until a hardware watchdog
reset it.

The receipt check now runs after the loop, after the resource
watchdogs, the same way those were moved. It still runs only on a pass
where the jobs ran (not while they were locked), on the same interval.

test_receipt_timeout_callback_can_send sends from a timeout handler.
Without this change, jobs() never returns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KbF8zYqrDkMpUrin37AMCv
@jamiecounsell
jamiecounsell force-pushed the receipt-timeout-after-jobs branch from 1e37e64 to 93d9ebf Compare November 15, 2026 15:52
@jamiecounsell

jamiecounsell commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

This PR now contains only the receipt-timeout change. It's been rebased onto master and is independent of #101; the two merge cleanly in either order.

Also added a native test where a timeout handler sends a packet. The Python RNS check of the watchdog changes is in the description of #101.

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.

2 participants