GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(rateLimit): take a `BurstyRateLimiter` for bursts by fratzinger · Pull Request #85 · feathersjs/feathers-utils

Conversation

@fratzinger

@fratzinger fratzinger commented Nov 6, 2026

Copy link
Copy Markdown
Member

Summary

rateLimit took a RateLimiterAbstract only. Its limiters count points per window, so a caller may spend them all at the window's start. rate-limiter-flexible already has the answer — BurstyRateLimiter, a steady limiter plus a burst one — but it isn't a RateLimiterAbstract, and it has no duration for the headers' window.

 export const rateLimit = (
-  rateLimiter: RateLimiterAbstract,
+  rateLimiter: RateLimiter, // RateLimiterAbstract | BurstyRateLimiter
   options?: RateLimitOptions<H>,
 ) => {
+  const steady = steadyOf(rateLimiter) // a BurstyRateLimiter's main limiter
   const infoFor = (res, limited) => ({
-    limit: rateLimiter.points,
-    window: rateLimiter.duration,
+    limit: steady.points,
+    window: steady.duration,
  • The headers report the steady limit; a call drawing on the burst has none of it left (remaining: 0).
  • The steady limiter is found by its shape (_rateLimiter), not instanceof: rate-limiter-flexible stays an optional peer, imported for types only, so loading the hooks without it keeps working.
  • Docs: a "Bursts" section with an example.

Evidence

BurstyRateLimiter(1 point / 60 s, burst 2 points / 60 s), headers 'draft-7'
  1st call → steady:  RateLimit-Policy "1;w=60", RateLimit "limit=1, remaining=0, reset=60"
  2nd, 3rd → burst:   pass, remaining=0
  4th      → TooManyRequests, retryAfter 60

Without the change, the window reads w=undefined and the limiter doesn't type-check.

pnpm test: 158 files, 2010 passed, no lint errors, no type errors.

Merge Danger

Door: two-way

Additive: the parameter's type widens, a RateLimiterAbstract behaves as before.

Blast Radius: none

Relies on BurstyRateLimiter's _rateLimiter field, which it has had since it was added; if it were renamed, the headers would read the bursty limiter's points and an empty window, and the limiting itself would still work.

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@fratzinger @claude
feat(rateLimit): take a BurstyRateLimiter for bursts
65ef952
A limiter counts its points per window, so a caller may spend them all at
its start. `rate-limiter-flexible`'s `BurstyRateLimiter` adds a burst above
a steady rate; the hook now takes it, and its headers report the steady
limit. Found by its shape: `rate-limiter-flexible` stays an optional peer,
imported for types only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 6, 2026

Copy link
Copy Markdown

Deploying feathers-utils with  Cloudflare Pages  Cloudflare Pages

Latest commit: 65ef952
Status: ✅  Deploy successful!
Preview URL: https://958a731a.feathers-utils.pages.dev
Branch Preview URL: https://feat-rate-limit-bursty.feathers-utils.pages.dev

View logs

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@fratzinger
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.