npm / @nestjs/throttler
@nestjs/throttler
What changed in @nestjs/throttler 5 to 6, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
10 breaking9 new APIs and options4 behavior and defaults1 tooling11 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@nestjs/throttler 623 changes
Breaking changes 5
The default tracker identifies NAT64 well-known prefix source addresses by their embedded IPv4 address instead of grouping IPv4 clients behind a gateway into one rate-limit bucket.
With blockDuration: 0, Retry-After reports when the oldest hit expires rather than when the window ends.
The built-in tracker masks IPv6 addresses to a subnet prefix, so clients within that subnet share a rate-limit counter. IPv6 tracker strings change shape, rotating storage keys once on upgrade.
A separate time will be provided to block requests, independently of the ttl; this is a breaking change for storage library owners.
Storage now uses Map instead of a simple object for key-value storage, improving performance in scenarios with frequent key additions and deletions; this is a breaking change for storage library owners.
New APIs and options 3
Adds a protected method subclasses can override to set rate limit headers; the guard uses res.setHeader() when res.header() is unavailable.
Configure the IPv6 subnet prefix length used by the default tracker.
Adds an option to control whether headers are added to the response.
Behavior and default changes 3
skipIf can return a promise, allowing the decision to skip throttling to depend on an asynchronous lookup; synchronous callbacks still work.
Storage no longer retains request contexts through per-hit timers; it records hit expiry times and prunes expired hits on access, and the idle-record sweep is no longer tied to the first request's context.
Idle records are removed after their window fully elapses and all pending hits and blocks have expired, preventing the in-memory map from growing indefinitely.
Tooling 1
Declares the supported Node versions in package engines, matching the range tested by the CI matrix.
Fixes and other changes 11
Using blockDuration: 0 no longer causes a stack overflow after a window holds more than about 125,000 hits, which previously made requests fail with a 500.
Every request is matched against ignoreUserAgents patterns with the g or y flag, preventing every other matching request from being counted against the limit.
Requests continue to be rejected with limit: 0 after a block has elapsed; the first hit after a block is now checked against the limit.
Request-scoped guards, including guards that depend on a request-scoped provider, no longer fail requests because onModuleInit() is not called on those instances.
Throttlers are sorted correctly when one uses a callback ttl, preventing a request rejected by a short throttler from being counted against a longer one.
Numeric strings are coerced to numbers, and an explicit 0 is respected; with blockDuration: 0, rejected requests are not recorded and can pass as soon as the oldest hit expires.
Numeric strings are coerced to numbers, and an explicit 0 in @Throttle() or module options is respected instead of falling back to the default.
The guard logs a warning at boot when no throttler is configured; it otherwise limits nothing.
Numeric strings are coerced to numbers, and an explicit 0 in @Throttle() or module options is respected instead of falling back to the default.
Updates the package to support Nest version 12.
Adds support for Nest version 11.
@nestjs/throttler 512 changes
Breaking changes 5
limit is no longer optional in module options; an option object must define defaults for its throttler.
Custom ThrottlerStorage implementations no longer need a storage property.
@Throttle() now accepts an object keyed by throttler context names, with limit and ttl values, instead of two parameters.
ttl is now measured in milliseconds rather than seconds; the seconds helper is available to ease migration.
ttl is no longer optional in module options; an option object must define defaults for its throttler.
New APIs and options 6
The seconds helper multiplies a ttl by 1000 to express it in milliseconds.
ThrottleGuard#shouldSkip enables conditionally skipping throttling.
A guard method allows the throttler message to be overridden.
Module options can now be an array or an object with a throttlers array property, enabling multiple throttler contexts.
@ThrottleSkip() now accepts an object whose string keys identify throttlers and whose boolean values specify which throttlers to skip.
The throw method receives extra context for customizing the message.
Behavior and default changes 1
getTracker can now be asynchronous.