effect
4.1.4 · 11 Nov 2026MIT66.6M / weekRepositoryHomepagenpmAtom feed
2.4.19 is the newest release of 2.x.
In short
3 fixed
Security
2 advisories affect 2.3.3; 3.22.1 fixes them
- HighEffect: ReDoS in Schema.TemplateLiteral compiled regexGHSA-7589-6fvf-x4pw · 19 Nov 2026Fixed in 3.22.1
- HighEffect `AsyncLocalStorage` context lost/contaminated inside Effect fibers under concurrent load with RPCGHSA-38f7-945m-qr2g · 20 Mar 2026Fixed in 3.20.0
Release note
Patch Changes
Update
RateLimiterto support passing in a customcostper effect. This is really useful for API(s) that have a "credit cost" per endpoint.Usage Example :
import { Effect, RateLimiter } from "effect"; import { compose } from "effect/Function"; const program = Effect.scoped( Effect.gen(function* ($) { // Create a rate limiter that has an hourly limit of 1000 credits const rateLimiter = yield* $(RateLimiter.make(1000, "1 hours")); // Query API costs 1 credit per call ( 1 is the default cost ) const queryAPIRL = compose(rateLimiter, RateLimiter.withCost(1)); // Mutation API costs 5 credits per call const mutationAPIRL = compose(rateLimiter, RateLimiter.withCost(5)); // ... // Use the pre-defined rate limiters yield* $(queryAPIRL(Effect.log("Sample Query"))); yield* $(mutationAPIRL(Effect.log("Sample Mutation"))); // Or set a cost on-the-fly yield* $( rateLimiter(Effect.log("Another query with a different cost")).pipe( RateLimiter.withCost(3), ), ); }), );Updates the
RateLimiter.makeconstructor to take an object ofRateLimiter.Options, which allows for specifying the rate-limiting algorithm to utilize:You can choose from either the
token-bucketor thefixed-windowalgorithms for rate-limiting.export declare namespace RateLimiter { export interface Options { /** * The maximum number of requests that should be allowed. */ readonly limit: number; /** * The interval to utilize for rate-limiting requests. The semantics of the * specified `interval` vary depending on the chosen `algorithm`: * * `token-bucket`: The maximum number of requests will be spread out over * the provided interval if no tokens are available. * * For example, for a `RateLimiter` using the `token-bucket` algorithm with * a `limit` of `10` and an `interval` of `1 seconds`, `1` request can be * made every `100 millis`. * * `fixed-window`: The maximum number of requests will be reset during each * interval. For example, for a `RateLimiter` using the `fixed-window` * algorithm with a `limit` of `10` and an `interval` of `1 seconds`, a * maximum of `10` requests can be made each second. */ readonly interval: DurationInput; /** * The algorithm to utilize for rate-limiting requests. * * Defaults to `token-bucket`. */ readonly algorithm?: "fixed-window" | "token-bucket"; } }Return the resulting available permits from Semaphore.release
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.