effect
4.1.4 · 11 Nov 2026MIT66.6M / weekRepositoryHomepagenpmAtom feed
2.4.19 is the newest release of 2.x.
In short
30 new1 fixed7 changed
Security
2 advisories affect 2.3.0; 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
Minor Changes
Change
Runtime.AsyncFiberExceptiontype parameters order fromAsyncFiberException<E, A>toAsyncFiberException<A, E = never>Change
Runtime.Canceltype parameters order fromCancel<E, A>toCancel<A, E = never>Change
Exittype parameter order fromExit<E, A>toExit<A, E = never>Change
Resourcetype parameters order fromResource<E, A>toResource<A, E = never>Change
FiberMaptype parameters order fromFiberMap<K, E = unknown, A = unknown>toFiberMap<K, A = unknown, E = unknown>With this change we now require a string key to be provided for all tags and renames the dear old
TagtoGenericTag, so when previously you could do:import { Effect, Context } from "effect"; interface Service { readonly _: unique symbol; } const Service = Context.Tag< Service, { number: Effect.Effect<never, never, number>; } >();you are now mandated to do:
import { Effect, Context } from "effect"; interface Service { readonly _: unique symbol; } const Service = Context.GenericTag< Service, { number: Effect.Effect<never, never, number>; } >("Service");This makes by default all tags globals and ensures better debuggaility when unexpected errors arise.
Furthermore we introduce a new way of constructing tags that should be considered the new default:
import { Effect, Context } from "effect"; class Service extends Context.Tag("Service")< Service, { number: Effect.Effect<never, never, number>; } >() {} const program = Effect.flatMap(Service, ({ number }) => number).pipe( Effect.flatMap((_) => Effect.log(`number: ${_}`)), );this will use "Service" as the key and will create automatically an opaque identifier (the class) to be used at the type level, it does something similar to the above in a single shot.
Change
Effecttype parameters order fromEffect<R, E, A>toEffect<A, E = never, R = never>Change
FiberSettype parameters order fromFiberSet<E, A>toFiberSet<A, E = never>Change
Runtime.RunCallbackOptionstype parameters order fromRunCallbackOptions<E, A>toRunCallbackOptions<A, E = never>Change
TDeferredtype parameters order fromTDeferred<E, A>toTDeferred<A, E = never>Change
Streamable.ClassandEffectable.Classtype parameters order fromClass<R, E, A>toClass<A, E = never, R = never>With this change we remove the
Data.Datatype and we makeEqual.Equal&Hash.Hashimplicit traits.The main reason is that
Data.Data<A>was structurally equivalent toA & Equal.Equalbut extendingEqual.Equaldoesn't mean that the equality is implemented by-value, so the type was simply adding noise without gaining any level of safety.The module
Dataremains unchanged at the value level, all the functions previously available are supposed to work in exactly the same manner.At the type level instead the functions return
Readonlyvariants, so for example we have:import { Data } from "effect"; const obj = Data.struct({ a: 0, b: 1, });will have the
objtyped as:declare const obj: { readonly a: number; readonly b: number; };Change
Deferredtype parameters order fromDeferred<E, A>toDeferred<A, E>Change
Fibertype parameters order fromFiber<E, A>toFiber<A, E = never>Change
Channeltype parameters order fromChannel<out Env, in InErr, in InElem, in InDone, out OutErr, out OutElem, out OutDone>toChannel<OutElem, InElem = unknown, OutErr = never, InErr = unknown, OutDone = void, InDone = unknown, Env = never>Change
Taketype parameters order fromTake<E, A>toTake<A, E = never>Change
STMtype parameters order fromSTM<R, E, A>toSTM<A, E = never, R = never>Change
Streamtype parameters order fromStream<R, E, A>toStream<A, E = never, R = never>Change
Pooltype parameters order fromPool<E, A>toPool<A, E = never>, andKeyedPoolfromKeyedPool<E, A>toKeyedPool<A, E = never>Change
Requesttype parameters order fromRequest<E, A>toRequest<A, E = never>Change
RuntimeFibertype parameters order fromRuntimeFiber<E, A>toRuntimeFiber<A, E = never>Use
TimeoutExceptioninstead ofNoSuchElementExceptionfor timeout.Change
Layertype parameters order fromLayer<RIn, E, ROut>toLayer<ROut, E = never, RIn = never>This change enables
Effect.serviceConstantsandEffect.serviceMembersto access any constant in the service, not only the effects, namely it is now possible to do:import { Effect, Context } from "effect"; class NumberRepo extends Context.TagClass("NumberRepo")< NumberRepo, { readonly numbers: Array<number>; } >() { static numbers = Effect.serviceConstants(NumberRepo).numbers; }Rename ReadonlyRecord.update to .replace
Enhance DX by swapping type parameters and adding defaults to:
Effect
async
asyncOption
asyncEither
Stream
asyncEffect
asyncInterrupt
asyncOption
asyncScoped
identity
Change
Sinktype parameters order fromSink<out R, out E, in In, out L, out Z>toSink<out A, in In = unknown, out L = never, out E = never, out R = never>Rename ReadonlyRecord.upsert to .set
Patch Changes
Add ReadonlyRecord.modify
Add
Ratelimiterwhich limits the number of calls to a resource within a time window using the token bucket algorithm.Usage Example:
import { Effect, RateLimiter } from "effect"; // we need a scope because the rate limiter needs to allocate a state and a background job const program = Effect.scoped( Effect.gen(function* ($) { // create a rate limiter that executes up to 10 requests within 2 seconds const rateLimit = yield* $(RateLimiter.make(10, "2 seconds")); // simulate repeated calls for (let n = 0; n < 100; n++) { // wrap the effect we want to limit with rateLimit yield* $(rateLimit(Effect.log("Calling RateLimited Effect"))); } }), ); // will print 10 calls immediately and then throttle program.pipe(Effect.runFork);Or, in a more real world scenario, with a dedicated Service + Layer:
import { Context, Effect, Layer, RateLimiter } from "effect"; class ApiLimiter extends Context.Tag("@services/ApiLimiter")< ApiLimiter, RateLimiter.RateLimiter >() { static Live = RateLimiter.make(10, "2 seconds").pipe( Layer.scoped(ApiLimiter), ); } const program = Effect.gen(function* ($) { const rateLimit = yield* $(ApiLimiter); for (let n = 0; n < 100; n++) { yield* $(rateLimit(Effect.log("Calling RateLimited Effect"))); } }); program.pipe(Effect.provide(ApiLimiter.Live), Effect.runFork);Simplify RateLimiter implementation using semaphore
Add Number.nextPow2
This function returns the next power of 2 from the given number.
import { nextPow2 } from "effect/Number"; assert.deepStrictEqual(nextPow2(5), 8); assert.deepStrictEqual(nextPow2(17), 32);
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.