Repository navigation
Keep the bunker serving through a lagged notification stream - #1074
Merged
Merged
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 12 minutes. View limit details
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. Comment |
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.
A NIP-46 bunker whose relay notifications fell behind stopped answering and reported a clean, intentional stop, with nothing logged.
Server::rundrove requests throughClient::handle_notifications, which in nostr-relay-pool 0.44.3 loops onwhile let Ok(notification) = notifications.recv().awaitover a broadcast channel of 4096. A receiver that falls more than that behind getsErr(Lagged), and that loop treats it exactly as it treats a shutdown: it ends and returnsOk(()). Reproduced: the dependency's loop on a lagged receiver handled none of the notifications still held and never reached the shutdown.It is reachable rather than theoretical because requests are handled one at a time, and an approval holds the loop for up to a minute on every surface since #1068. A busy relay can queue 4096 notifications in that time.
The loop is now driven directly from the receiver:
Shutdownnotification is a clean stop, as before.Ok(()), so a caller can tell it from a stop it asked for. On mobile that reports the bunker as errored instead of stopped.The loop is a separate function taking the receiver, so a test can lag it deterministically with a small channel. Tests cover a lagged receiver serving on until the real shutdown and handling what it still held, a stream closing without a shutdown being reported as such, and a shutdown being a clean stop. Making the lag end the loop again fails the first.
Not changed: requests are still handled one at a time, so a slow approval still delays later ones. Handling them concurrently would race the rate limiters and the per-app permission counters, which rely on that ordering today.