A relay that never answers the dial no longer holds req and fetch - #20
Merged
Merged
Conversation
The relays were dialled one after another with no deadline, and --timeout only started counting once every dial had returned. A relay that accepted the connection and never answered the websocket upgrade held the run forever, and the relays listed after it were never reached. Every relay is now dialled at once, under a bound of five seconds or --timeout if that is shorter. A relay still dialling at the bound is cancelled, named on stderr, and left out, and the run carries on with the ones that answered. This needs nostr 0.14.4, where a cancelled dial stops at once and frees what it allocated, so the pin moves to it. Tests dial a real relay on loopback: one that never answers, a closed port and a live one, all at once and inside the deadline. Refs #19.
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.
Refs #19. This covers
reqandfetch;publishdials the same way and moves onto the same path in the change that reworks what it returns.The relays were dialled one after another with no deadline, and
--timeoutonly started counting once every dial had returned. A relay that accepted the connection and never answered the websocket upgrade held the run forever, and the relays listed after it were never reached.What changes
no answer within <n> ms, and left out. The run carries on with the relays that answered.--timeoutif that is shorter.--timeoutstill covers the wait for answers once the relays are reached.reqandfetchsays what the bound is.Checked against real relays
--timeout 2000Tests
The tests dial a real relay over loopback, through the same
diala run uses:a silent relay times out, a closed port fails, and a live relay connects, all at oncechecks each outcome and that the whole thing takes the deadline, not the slowest relay. With the timer made to fire late, it fails.a relay that never answers the dial costs the run its deadline, not foreverputs the silent relay first, ahead of a live one, and requires the live relay to answer and the run to finish.Dialling tests use a leak-checked allocator that captures no stack traces. On macOS a stack capture can swallow a pending cancel, and the test would hang instead of failing. The test relay serves one connection and returns for the same reason. The suite passed 20 runs of 20 with no hang.
All 70 tests pass.