Skip to content

fix(relay): answer error when event rate limiter is unavailable (#1300) - #1346

Open
avantikonde wants to merge 1 commit into
rewrite/mainfrom
fix/1300-unavailable-limiter-error
Open

avantikonde wants to merge 1 commit into
rewrite/mainfrom
fix/1300-unavailable-limiter-error

Conversation

@avantikonde

@avantikonde avantikonde commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Updates the unavailable event rate limiter branch in crates/nostream-relay/src/handlers/event.rs to reply error: rate limiter unavailable (with no backoff) instead of rate-limited: slow down, updates a_failing_event_limiter_limits_the_event_without_a_backoff in crates/nostream-relay/tests/limits.rs to assert both the OK frame and the error rejection metric label, and corrects ADR 0004 (docs/rewrite/decisions/0004-wire-transport.md).

Related Issue

Closes #1300

Motivation and Context

In the capture (src/handlers/event-message-handler.ts:136-144), an unavailable event rate limiter answers error: rate limiter unavailable with no backoff so connected clients do not back off together for an outage on the relay's side. Previously, crates/nostream-relay/src/handlers/event.rs:101 answered rate-limited: slow down, and ADR 0004 stated that matched the capture.

HandlerContext::send_ok routes rejections through RelayMetrics::event_rejected, so answering error: rate limiter unavailable also records the rejection under nostream_events_rejected_total{reason="error"} rather than rate-limited.

How Has This Been Tested?

  • Updated a_failing_event_limiter_limits_the_event_without_a_backoff in crates/nostream-relay/tests/limits.rs to assert ["OK","<id>",false,"error: rate limiter unavailable"], events_rejected("error") == 1, and events_rejected("rate-limited") == 0.
  • Ran the full nostream-relay test suite (cargo test -p nostream-relay): 320 passed, 0 failed across all 13 test targets (lib, config_defaults, connection, handlers, hidden_content, limits, metrics, nip11, nip_vectors, strategies, transport, ts_case_parity, wire_parity).
  • Ran formatting and linter checks:
    • cargo fmt --all --check
    • cargo clippy -p nostream-relay --all-targets --all-features -- -D warnings
    • Strict workspace clippy on --lib --bins --all-features with -D warnings -D clippy::unwrap_used -D clippy::expect_used -D clippy::todo -D clippy::unimplemented -D clippy::panic
    • cargo check -p nostream-storage --no-default-features --all-targets

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • I added a changeset, or this is docs-only and I added an empty changeset.
  • All new and existing tests passed.

@coderabbitai

coderabbitai Bot commented Dec 2, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 85030203-938c-4f8e-b735-4dcee5db6238

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@greptile-apps

greptile-apps Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] This PR appears safe to merge.

Summary

Changes the unavailable event limiter response to error: rate limiter unavailable, with no backoff.

  • Event submissions get an error reply when the limiter is unavailable.

Reviews (1) · Last reviewed commit: "fix(relay): answer error when event rate..." · Reviewed by Greptile

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant