Repository navigation
Conversation
NostrWsConnection answers the relay's pings inside its receive loops and never returns them, so a caller has no way to see that an otherwise idle socket is still alive. The relay pings every connection every 30 s; a client stall watchdog that counts inbound frames, as desktop's relayStallWatchdog does, sees an idle healthy socket as silent and tears it down. Every receive loop (recv_one, wait_for_auth_challenge, wait_for_ok) now stamps the arrival of each frame, Ping, Pong and Close included, and last_frame_at() returns it: the connect time until the first frame. The crate's tests join the unit lane, since nothing ran them before. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Jason Holmes <holmes@squareup.com>
🔐 Codex Security Review
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NostrWsConnectionanswers the relay's WebSocket pings inside its receive loops and never returns them. So a client that detects stalled sockets by watching for inbound frames cannot see the relay's heartbeat. The relay pings every connection every 30 s and closes it after three missed pongs (heartbeat_loopincrates/buzz-relay/src/connection.rs). Desktop'srelayStallWatchdogcounts any inbound frame, the relay's pings included, as proof the socket is alive. A Rust client on this crate cannot do the same: to it, an idle, healthy socket looks silent, and a stall watchdog tears it down. ManagerBot's mobile core runs a 60 s stall watchdog, and it reconnected idle sockets about every 72 s for this reason.This PR adds
NostrWsConnection::last_frame_at() -> tokio::time::Instant: when the last frame of any kind (Text, Ping, Pong or Close) arrived from the relay. All three receive loops record it:recv_one,wait_for_auth_challengeandwait_for_ok. Until the first frame arrives, it holds the connect time. The change is additive; no existing signature or behaviour changes.buzz-ws-client's tests were in neither unit lane, so this also adds the crate tojust test-unitand to thescripts/run-tests.shfallback.Related issue
None found.
Testing
a_ping_alone_advances_last_frame_at: a loopback relay sends one Ping and then stays silent.next_eventtimes out with nothing returned, the relay receives the Pong, andlast_frame_at()has advanced. With the stamp inrecv_oneremoved, the test fails.cargo test -p buzz-ws-client --libcargo clippy -p buzz-ws-client -p buzz-cli -p buzz-test-client --all-targets -- -D warningscargo fmt --all -- --check,just file-size-check, and the pre-push hooks, includingjust test-unit🤖 Generated with Claude Code