effect
4.1.4 · 11 Nov 2026MIT66.6M / weekRepositoryHomepagenpmAtom feed
3.22.5 is the newest release of 3.x.
In short
1 deprecated13 new5 fixed1 internal
- Deprecated
Stream: Use new built-in
Types.TupleOfinstead ofStream.DynamicTupleand deprecate it
Security
2 advisories affect 3.5.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
Add renderErrorCause option to Cause.pretty
Add RcRef module
An
RcRefwraps a reference counted resource that can be acquired and released multiple times.The resource is lazily acquired on the first call to
getand released when the last reference is released.import { Effect, RcRef } from "effect"; Effect.gen(function* () { const ref = yield* RcRef.make({ acquire: Effect.acquireRelease(Effect.succeed("foo"), () => Effect.log("release foo"), ), }); // will only acquire the resource once, and release it // when the scope is closed yield* RcRef.get(ref).pipe(Effect.andThen(RcRef.get(ref)), Effect.scoped); });Allowing customizing Stream pubsub strategy
import { Schedule, Stream } from "effect"; // toPubSub Stream.fromSchedule(Schedule.spaced(1000)).pipe( Stream.toPubSub({ capacity: 16, // or "unbounded" strategy: "dropping", // or "sliding" / "suspend" }), ); // also for the broadcast apis Stream.fromSchedule(Schedule.spaced(1000)).pipe( Stream.broadcastDynamic({ capacity: 16, strategy: "dropping", }), );Add Duration.isZero, for checking if a Duration is zero
Add
Successtype util forConfig.Add Logger.prettyLogger and Logger.pretty
Logger.prettyis a new logger that leverages the features of theconsoleAPIs to provide a more visually appealing output.To try it out, provide it to your program:
import { Effect, Logger } from "effect"; Effect.log("Hello, World!").pipe(Effect.provide(Logger.pretty));Add .groupCollapsed to UnsafeConsole
Export Random.make taking hashable values as seed
Add
replayoption to PubSub constructorsThis option adds a replay buffer in front of the given PubSub. The buffer will
replay the lastnmessages to any new subscriber.Effect.gen(function*() { const messages = [1, 2, 3, 4, 5] const pubsub = yield* PubSub.bounded<number>({ capacity: 16, replay: 3 }) yield* PubSub.publishAll(pubsub, messages) const sub = yield* PubSub.subscribe(pubsub) assert.deepStrictEqual(Chunk.toReadonlyArray(yield* Queue.takeAll(sub)), [3, 4, 5]) }))Add RcMap module
An
RcMapcan contain multiple reference counted resources that can be indexed
by a key. The resources are lazily acquired on the first call togetand
released when the last reference is released.Complex keys can extend
EqualandHashto allow lookups by value.import { Effect, RcMap } from "effect"; Effect.gen(function* () { const map = yield* RcMap.make({ lookup: (key: string) => Effect.acquireRelease(Effect.succeed(`acquired ${key}`), () => Effect.log(`releasing ${key}`), ), }); // Get "foo" from the map twice, which will only acquire it once // It will then be released once the scope closes. yield* RcMap.get(map, "foo").pipe( Effect.andThen(RcMap.get(map, "foo")), Effect.scoped, ); });Ensure
Scopeis excluded fromRin theChannel/Streamrun*functions.This fix ensures that
Scopeis now properly excluded from the resulting effect environment.
The affected functions includerun,runCollect,runCount,runDrainand other non-scopedrun*in bothStreamandChannelmodules.
This fix brings the type declaration in line with the runtime implementation.Stream: Implement "raceAll" operator, which returns a stream that mirrors the first source stream to emit an item.
import { Stream, Schedule, Console, Effect } from "effect"; const stream = Stream.raceAll( Stream.fromSchedule(Schedule.spaced("1 millis")), Stream.fromSchedule(Schedule.spaced("2 millis")), Stream.fromSchedule(Schedule.spaced("4 millis")), ).pipe(Stream.take(6), Stream.tap(Console.log)); Effect.runPromise(Stream.runDrain(stream)); // Output only from the first stream, the rest streams are interrupted // 0 // 1 // 2 // 3 // 4 // 5- Deprecated
Stream: Use new built-in
Types.TupleOfinstead ofStream.DynamicTupleand deprecate it Support ErrorOptions in YieldableError constructor
Allow customizing the output buffer for the Stream.async* apis
import { Stream } from "effect"; Stream.async<string>( (emit) => { // ... }, { bufferSize: 16, strategy: "dropping", // you can also use "sliding" or "suspend" }, );
Patch Changes
Include Error.cause stack in log output
Set stackTraceLimit to 1 in PrettyError to address performance issues
Ensure "cause" is rendered in Data.Error output
Fix types of UnsafeConsole.group
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.