relay.py: include error detail + URL in on_error print#1
Open
bitcoin3us wants to merge 1 commit intoMicroPythonOS:mainfrom
Open
relay.py: include error detail + URL in on_error print#1bitcoin3us wants to merge 1 commit intoMicroPythonOS:mainfrom
bitcoin3us wants to merge 1 commit intoMicroPythonOS:mainfrom
Conversation
Previously the on_error callback printed a bare 'relay.py got error'
with no exception info and no relay URL. When a WebSocket connection
to a relay fails (TLS handshake, DNS, connection reset, socket
exhaustion, etc.) there's no way to tell from logs *what* went wrong
or *which* relay in a multi-relay configuration.
Encountered while debugging NWC connect failures on ESP32 — had to
patch the library locally to surface the exception type, only to
discover it was a socket-pool exhaustion issue that resolved after
the caller closed its old sockets. The diagnostic would have been
obvious from the log had `error` been printed.
Change:
print("relay.py got error")
→
print("relay.py got error for {}: {!r}".format(self.url, error))
repr() on the exception gives both the type and the args/message,
which is what you want for diagnostics. Backwards-compatible at the
callback level (same signature, same flow).
14 tasks
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
The
_on_errorcallback innostr/relay.pycurrently prints a barerelay.py got errorwith no exception info and no relay URL. When a WebSocket connection fails (TLS handshake, DNS, connection reset, socket exhaustion, etc.) there's nothing in the log to tell you what went wrong or which relay in a multi-relay configuration.Discovery
Encountered while debugging NWC connect failures on an ESP32 running MicroPythonOS. The device kept reporting "Could not connect to any Nostr Wallet Connect relays" with no explanation — only
relay.py got errorin serial. Had to patch this file locally to surface the exception before the real issue (socket-pool exhaustion from a stale LNBits WebSocket) became visible.Fix
repr()on the exception gives both the type and the args/message, which is what you want for diagnostics. No behaviour change — same signature, same control flow, reconnect logic untouched.Example output
Before:
After (illustrative):
One line, enough signal to point at DNS vs TLS vs socket exhaustion vs protocol issues.
Test plan
_on_closestill fires (unchanged)_on_openstill fires (unchanged)🤖 Generated with Claude Code