You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(relay): answer error when event rate limiter is unavailable (#1300) - #1346
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).
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).
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.
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
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
Updates the unavailable event rate limiter branch in
crates/nostream-relay/src/handlers/event.rsto replyerror: rate limiter unavailable(with no backoff) instead ofrate-limited: slow down, updatesa_failing_event_limiter_limits_the_event_without_a_backoffincrates/nostream-relay/tests/limits.rsto assert both the OK frame and theerrorrejection 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 answerserror: rate limiter unavailablewith 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:101answeredrate-limited: slow down, and ADR 0004 stated that matched the capture.HandlerContext::send_okroutes rejections throughRelayMetrics::event_rejected, so answeringerror: rate limiter unavailablealso records the rejection undernostream_events_rejected_total{reason="error"}rather thanrate-limited.How Has This Been Tested?
a_failing_event_limiter_limits_the_event_without_a_backoffincrates/nostream-relay/tests/limits.rsto assert["OK","<id>",false,"error: rate limiter unavailable"],events_rejected("error") == 1, andevents_rejected("rate-limited") == 0.nostream-relaytest 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).cargo fmt --all --checkcargo clippy -p nostream-relay --all-targets --all-features -- -D warnings--lib --bins --all-featureswith-D warnings -D clippy::unwrap_used -D clippy::expect_used -D clippy::todo -D clippy::unimplemented -D clippy::paniccargo check -p nostream-storage --no-default-features --all-targetsTypes of changes
Checklist: