fix(relay): don't exit when a UDP reply bounces - #84
Merged
Conversation
The registrar replies to packets it cannot parse. If the sender has gone, that reply provokes an ICMP unreachable, which arrives back on the socket as ECONNREFUSED. With no error handler the process exits. The relay sockets in src/relay/relay.ts already handle this; the registrar was missed. Refs foxssake#74
elementbound
force-pushed
the
fix/registrar-socket-error
branch
from
August 3, 2026 18:36
bf836d8 to
13fdb8e
Compare
|
Thanks for the fix @Jaedee! Happy to look at more PRs if you're willing to send! |
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.
📓 Description
A single UDP packet from any source can stop noray.
UDPRemoteRegistrar.listen()creates its socket with adatahandler but noerrorhandler. When a packet arrives that is not a valid PID,handle()catches the assertion and replies with the error message. If the sender has
gone — a port scanner, a stray packet, a client that has moved on — that reply
provokes an ICMP port-unreachable, which surfaces on the socket as
ECONNREFUSED. With no handler, Bun treats it as fatal and the process exits.Reproduced on 1 August 2026 against
c0c34dc, withNORAY_UDP_REGISTRAR_PORTreachable from the internet:
systemd restarted it and the next stray packet killed it again. In our case it
had been restarting every few seconds for an hour before we noticed, which made
every other measurement meaningless — ports appeared closed, join codes were
issued and then were not, and nothing reproduced twice.
The fix copies the handler
bindPortForRelayingalready installs on the relaysockets in
src/relay/relay.ts. After it, the same packet logs a line and theprocess carries on:
Verified against a live instance: the packet that previously killed it, then an
empty packet, binary junk, a 2KB payload and a TCP command sent over UDP — all
logged, same PID throughout, and the instance kept issuing OIDs between them.
☑️ Checklist
🔗 Related issues
Partially addresses #74 — this is one of the "thrown inside an event handler"
cases. Same family as #54.
Happy to widen it to the other sockets in the relay module if you would rather
have that in one go, but I have only reproduced this one.