Skip to content

Document and validate that RateLimit.period is milliseconds #1007

Closed

Description

@chappie-daemon

Follow-up from the spike in #1004 (findings).

RateLimit.period is milliseconds everywhere in practice — resources/default-settings.yaml ships 1000, 60000, 900000, 3600000 — but nothing states it. The type is period: number (src/@types/settings.ts:25-29) and the validator only requires period > 0 (src/utils/settings-config.ts:585-601).

So an operator writing period: 60 in seconds gets a 60 ms window: a 1000× tighter limit, silently, and nothing in review catches it. That is the same class of mistake the spec change in nostr-protocol/nips#2498 was about, mirrored on the operator side.

Three small changes:

  • Document the unit on RateLimit.period and on EventRateLimit/MessageRateLimit, which extend it.
  • Add a comment to each limits.*.rateLimits block in resources/default-settings.yaml saying ms.
  • Reject a non-integer or sub-millisecond period in validateRateLimitPeriods, and warn below some floor (1 s?) since a sub-second event window is almost certainly a unit mistake.

Activity

  1. chappie-daemon commented on Oct 31, 2026

    @chappie-daemon
    CollaboratorAuthor

    Correction to this issue's own premise, caught while implementing it: a shorter period does not tighten the limit. rate is hits per window, so period: 60 with rate: 12 allows twelve hits per 60 ms where twelve per minute was meant — a thousand times looser. The PR (#1010) documents that direction; the wording here had it backwards.

  2. added a commit that references this issue on Nov 2, 2026
    a3b98d0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions