feat: answer REQ with CLOSED when no relay is configured #5

Merged
padreug merged 2 commits from feat/closed-on-req into main 2026-09-13 14:12:48 +00:00
Owner

What

Port of the one piece of the upstream PR (lnbits/nostrclient#74) that isn't in our fork yet: a REQ received while nostrclient has no relay configured at all is answered with ["CLOSED", <sub_id>, "error: no relay connections"] and not registered. Idea taken from lnbits/nostrclient#68 (BenGWeeks), credited there.

Deliberately keyed on "no relay configured", not "none connected": a configured relay that is merely reconnecting gets the cached subscription replayed by the relay manager, so refusing the REQ in that state would be a regression. The OK path (PR #3) keeps using connected relays, which is the right condition for a one-shot publish.

router.py, tests/test_router_ok.py and the README line are byte-identical to what was pushed upstream, so the fork and upstream stay aligned for the eventual rebase (#4).

Verification

  • pytest nostrclient/tests: 9 passed (2 new: CLOSED when nothing configured; subscription kept when a configured relay is disconnected).
  • ruff clean.

Release

Version bumped to 1.2.0-aio.3 in a separate commit. After merge: tag, hash, new catalog entry (keep 1.2.0-aio.2).

Upstream state

  • lnbits/nostrclient#74 — this + the OK reply, opened 2026-09-13.
  • lnbits/nostrrelay#45 — the deliver-to-every-subscription fix, opened 2026-09-13.
  • Comment left on lnbits/nostrclient#68 linking #74 and suggesting the two minimal fixes if the maintainers prefer that patch.

🤖 Generated with Claude Code

https://claude.ai/code/session_013Tbyw6FwjhEJg3gHfPHxWt

## What Port of the one piece of the upstream PR (lnbits/nostrclient#74) that isn't in our fork yet: a `REQ` received while nostrclient has **no relay configured at all** is answered with `["CLOSED", <sub_id>, "error: no relay connections"]` and not registered. Idea taken from lnbits/nostrclient#68 (BenGWeeks), credited there. Deliberately keyed on "no relay configured", not "none connected": a configured relay that is merely reconnecting gets the cached subscription replayed by the relay manager, so refusing the REQ in that state would be a regression. The OK path (PR #3) keeps using *connected* relays, which is the right condition for a one-shot publish. `router.py`, `tests/test_router_ok.py` and the README line are byte-identical to what was pushed upstream, so the fork and upstream stay aligned for the eventual rebase (#4). ## Verification - `pytest nostrclient/tests`: 9 passed (2 new: CLOSED when nothing configured; subscription kept when a configured relay is disconnected). - ruff clean. ## Release Version bumped to `1.2.0-aio.3` in a separate commit. After merge: tag, hash, new catalog entry (keep `1.2.0-aio.2`). ## Upstream state - lnbits/nostrclient#74 — this + the OK reply, opened 2026-09-13. - lnbits/nostrrelay#45 — the deliver-to-every-subscription fix, opened 2026-09-13. - Comment left on lnbits/nostrclient#68 linking #74 and suggesting the two minimal fixes if the maintainers prefer that patch. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_013Tbyw6FwjhEJg3gHfPHxWt
Ported from the upstream PR (lnbits/nostrclient#74, idea from #68).
Nothing will ever serve a subscription when nostrclient has no relay
at all, so refuse it per NIP-01 instead of registering it silently.
Keyed on "no relay configured" rather than "none connected": a
configured relay that is merely reconnecting gets the cached
subscription replayed, so refusing the REQ there would be a regression.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Tbyw6FwjhEJg3gHfPHxWt
chore: bump version to 1.2.0-aio.3
Some checks failed
ci.yml / chore: bump version to 1.2.0-aio.3 (pull_request) Failing after 0s
c4c1a1c342
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Tbyw6FwjhEJg3gHfPHxWt
padreug deleted branch feat/closed-on-req 2026-09-13 14:12:48 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
aiolabs/nostrclient!5
No description provided.