effect
4.1.4 · 11 Nov 2026MIT67.1M / weekRepositoryHomepagenpmAtom feed
3.22.5 is the newest release of 3.x.
In short
2 new10 fixed
Security
2 advisories affect 3.12.6; 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
Schema: Enhance error messages for discriminated unions.
Before
import { Schema } from "effect" const schema = Schema.Union( Schema.Tuple(Schema.Literal(-1), Schema.Literal(0)).annotations({ identifier: "A" }), Schema.Tuple(Schema.NonNegativeInt, Schema.NonNegativeInt).annotations({ identifier: "B" }) ).annotations({ identifier: "AB" }) Schema.decodeUnknownSync(schema)([-500, 0]) /* throws: ParseError: AB ├─ { readonly 0: -1 } │ └─ ["0"] │ └─ Expected -1, actual -500 └─ B └─ [0] └─ NonNegativeInt └─ From side refinement failure └─ NonNegative └─ Predicate refinement failure └─ Expected a non-negative number, actual -500 */After
import { Schema } from "effect" const schema = Schema.Union( Schema.Tuple(Schema.Literal(-1), Schema.Literal(0)).annotations({ identifier: "A" }), Schema.Tuple(Schema.NonNegativeInt, Schema.NonNegativeInt).annotations({ identifier: "B" }) ).annotations({ identifier: "AB" }) Schema.decodeUnknownSync(schema)([-500, 0]) /* throws: ParseError: AB -├─ { readonly 0: -1 } +├─ A │ └─ ["0"] │ └─ Expected -1, actual -500 └─ B └─ [0] └─ NonNegativeInt └─ From side refinement failure └─ NonNegative └─ Predicate refinement failure └─ Expected a non-negative number, actual -500 */Added type-level validation for the
Effect.Servicefunction to ensure theSelfgeneric parameter is provided. If the generic is missing, theMissingSelfGenerictype will be returned, indicating that the generic parameter must be specified. This improves type safety and prevents misuse of theEffect.Servicefunction.type MissingSelfGeneric = `Missing \`Self\` generic - use \`class Self extends Service<Self>()...\``
Improve
UnknownExceptionerror messagesUnknownExceptionerror messages now include the name of the Effect api that
created the error.import { Effect } from "effect" Effect.tryPromise(() => Promise.reject(new Error("The operation failed")) ).pipe(Effect.catchAllCause(Effect.logError), Effect.runFork) // timestamp=2025-01-21T00:41:03.403Z level=ERROR fiber=#0 cause="UnknownException: An unknown error occurred in Effect.tryPromise // at fail (.../effect/packages/effect/src/internal/core-effect.ts:1654:19) // at <anonymous> (.../effect/packages/effect/src/internal/core-effect.ts:1674:26) { // [cause]: Error: The operation failed // at <anonymous> (.../effect/scratchpad/error.ts:4:24) // at .../effect/packages/effect/src/internal/core-effect.ts:1671:7 // }"Schema: Enforce Finite Durations in
DurationFromNanos.This update ensures that
DurationFromNanosonly accepts finite durations. Previously, the schema did not explicitly enforce this constraint.A filter has been added to validate that the duration is finite.
DurationFromSelf +.pipe( + filter((duration) => duration_.isFinite(duration), { + description: "a finite duration" + }) )Duration: Make
DurationValueproperties readonly.Array: Fix
Eitherimport and correctpartitionexample.Schema: Fix
BigIntFromNumberto enforce upper and lower bounds.This update ensures the
BigIntFromNumberschema adheres to safe integer limits by applying the following bounds:BigIntFromSelf + .pipe( + betweenBigInt( + BigInt(Number.MIN_SAFE_INTEGER), + BigInt(Number.MAX_SAFE_INTEGER) + ) + )
Fixed conflicting
ParseErrortags betweenCronandSchemaEnsure cause is rendered in FiberFailure
Schema: Add Support for Infinity in
Duration.This update adds support for encoding
Duration.infinityinSchema.Duration.Before
Attempting to encode
Duration.infinityresulted in aParseErrordue to the lack of support forInfinityinSchema.Duration:import { Duration, Schema } from "effect" console.log(Schema.encodeUnknownSync(Schema.Duration)(Duration.infinity)) /* throws: ParseError: Duration └─ Encoded side transformation failure └─ HRTime └─ [0] └─ NonNegativeInt └─ Predicate refinement failure └─ Expected an integer, actual Infinity */After
The updated behavior successfully encodes
Duration.infinityas[ -1, 0 ]:import { Duration, Schema } from "effect" console.log(Schema.encodeUnknownSync(Schema.Duration)(Duration.infinity)) // Output: [ -1, 0 ]Schema: Update
plucktype signature to respect optional fields.Before
import { Schema } from "effect" const schema1 = Schema.Struct({ a: Schema.optional(Schema.String) }) /* const schema2: Schema.Schema<string | undefined, { readonly a: string | undefined; }, never> */ const schema2 = Schema.pluck(schema1, "a")After
import { Schema } from "effect" const schema1 = Schema.Struct({ a: Schema.optional(Schema.String) }) /* const schema2: Schema.Schema<string | undefined, { readonly a?: string | undefined; }, never> */ const schema2 = Schema.pluck(schema1, "a")Update
Cause.isCausetype from 'never' to 'unknown'
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.