Survive transient relay crashes + add restart policy#20
Merged
Conversation
A relay reconnect storm made nostr-tools throw SendingOnClosedConnection asynchronously from a WebSocket 'open' handler (it re-fires a subscription on a socket that closed mid-reconnect). The throw escapes our try/catch and surfaced as an uncaughtException that killed the bunker process; with no restart policy the container then stayed down for days. - Add process guards (uncaughtException/unhandledRejection): swallow the transient relay error (the watchdog re-subscribes shortly after) and exit on any genuine fault so the container restarts cleanly. - Add `restart: unless-stopped` to all docker-compose services so a crash or host reboot auto-recovers instead of leaving the bunker offline.
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.
Problem
Production bunker was offline for ~2 days. The server process crashed on an uncaught
SendingOnClosedConnectionthrown bynostr-toolsasynchronously from a WebSocketopenhandler — during a relay reconnect storm a subscription re-fired on a socket that had closed mid-reconnect. The throw happens in the ws event loop, not our call stack, so thetry/catcharoundpool.subscribecan't catch it. With norestart:policy in compose, the container then stayed down.Fix
uncaughtException/unhandledRejection): swallow the transient relay error (the connection watchdog re-subscribes the dropped relay shortly after) andexit(1)on any genuine fault, so a real bug still fails fast and the container restarts cleanly instead of limping in an undefined state. Unit-tested.restart: unless-stoppedon all compose services so a crash or host reboot auto-recovers.Notes
docker update --restart unless-stoppedto the live mini7 containers as an immediate mitigation; this PR makes it surviveup -d --build.relay.primal.net/relay.damus.iowere rejecting withtoo many concurrent REQs), which is what triggers the transient error.