What changed in Effect 4 when you build a backend

By Esteban Trillo7 min readupdated Effect on the BackendEffectTypeScript

Same install line. The package it asks for has no v4.
Same install line. The package it asks for has no v4.

Part 1 of a series that builds one backend server on Node with Effect 4, a part at a time. It picks up where Learning Effect stops. The code lives in devtrillo/effect-on-the-backend, and every part is a tag.

Copy the install line from any Effect 3 server tutorial, pin the new major, and npm refuses:

npm i effect@4.0.5 @effect/platform
npm error code ERESOLVE
npm error Found: effect@4.0.5
npm error peer effect@"^3.22.2" from @effect/platform@0.97.2

effect@latest is 4.0.5. @effect/platform@latest is still 0.97.2, and it wants Effect 3. There is no Effect 4 version of that package, and there isn’t going to be one.

Moving Learning Effect to Effect 4 only changed a few names. The Context.Service class syntax is in part 8, Effect.catch (Effect 3 called it catchAll) is in part 6, and AsyncFiberError is in part 9. Then I started on a server, and the list got longer. This post is the rest of that list.

One package, one version

Effect 4.0.0 shipped on October 1, 2026. The announcement calls it “rebuilt from the ground up, with a dependency-free core and long-term support.”1 They mean it literally. effect@3.22.3 depends on fast-check and @standard-schema/spec. effect@4.0.5 depends on nothing.

The bigger change is that @effect/platform, @effect/rpc, @effect/cluster and others merged into effect itself.2 This is what a clean install of @effect/platform-node took on Effect 3. It isn’t from the series repo:

package.json (Effect 3)
"dependencies": {
"effect": "^3.22.3",
"@effect/platform": "^0.97.2",
"@effect/platform-node": "^0.108.3",
"@effect/rpc": "^0.76.3",
"@effect/sql": "^0.52.1",
"@effect/cluster": "^0.60.4",
"@effect/workflow": "^0.19.1"
}

Seven packages on seven version lines, because platform-node peers on the rest. The series repo needs two:

package.json (part-1)
"dependencies": {
"@effect/platform-node": "4.0.5",
"effect": "4.0.5"
},

Every package now shares one version and releases in lockstep. If you use effect@4.0.0, “the matching SQL package is @effect/sql-pg@4.0.0.”2 The packages that stay separate are the ones that talk to something outside: @effect/platform-* for runtimes, @effect/sql-* for drivers, plus @effect/ai-*, @effect/opentelemetry and @effect/vitest.

Effect 4 also comes with an LTS promise: bug fixes until September 2029 or a year after 5.0, whichever is later.1 A server you’ll run for years cares about that. A script doesn’t.

Your Effect 3 server depends on effect, @effect/platform, @effect/platform-node and @effect/sql. What does the dependency list look like on 4.0.5?

Where things moved

The modules didn’t disappear. They moved under effect/, and there are no compatibility exports for the old paths.2 These are the ones a server touches:3

Effect 3 Effect 4
@effect/platform/HttpRouter effect/http (HttpRouter)
@effect/platform/HttpApi effect/http-api (HttpApi)
@effect/platform/FileSystem effect/FileSystem
@effect/sql effect/sql
effect/Either effect/Result
effect/FiberRef effect/References

If you tried a v4 beta, these paths had an unstable/ segment, as in effect/unstable/http. That’s gone too, but dropping the segment didn’t make the modules stable. The guide says it plainly: “Moving these modules does not stabilize their APIs.”2

Each module carries a @stability tag in its type definitions. Effect, Context, Layer and Schema are stable, so they follow strict semver. effect/http, effect/http-api and effect/sql are unstable, which means they can break in a minor release.2 This series builds on exactly those modules, so the repo pins 4.0.5 with no caret, and each part bumps it on purpose.

Services: you write the layer now

Learning Effect covers the new class syntax. What it doesn’t cover is the v3 shortcut most backend code used, Effect.Service. You gave it a constructor and a list of dependencies, and it generated a .Default layer for you.

In v4 there’s one way to define a service, Context.Service. With a make option it stores the constructor on the class but “does not auto-generate a layer.”4 In the morph below, the Effect 4 side is the Users service from the series repo. The Effect 3 side is my sketch of the same service written with Effect.Service, and it isn’t in the repo:

That one line is the whole migration for a service with no dependencies. When it has some, the dependencies option is gone, and you add .pipe(Layer.provide(...)) to the layer yourself.4 The naming changed with it: the main layer is layer, and variants get suffixes like layerTest, instead of v3’s Default or Live.

Static accessors are gone too. In v3 you could call Users.find("1") straight off an Effect.Tag class. The proxy behind that was a mapped type, and it “lost” generic type parameters and overloads.4 In v4 you yield the service, or use Users.use((users) => users.find("1")). The guide says to prefer yield*, because use hides the dependency from the call site. Here’s the repo’s whole entry point:

src/main.ts
import { Effect } from "effect"
import { Users } from "./Users.ts"
const program = Effect.gen(function* () {
const users = yield* Users
const user = yield* users.find("1")
console.log(`found ${user.name}`)
})
Effect.runPromise(program.pipe(Effect.provide(Users.layer)))

Note the .ts in the import. Node 24 runs TypeScript files directly by stripping the types, so the repo has no build step. npm start is node src/main.ts, and it prints found Ada. The tsconfig turns on allowImportingTsExtensions, noEmit and erasableSyntaxOnly, so tsc only checks, and it rejects syntax like enum that Node can’t strip.

Errors: more than catchAll

catchAll became catch, and the rest of the family moved with it:5

Effect 3 Effect 4
catchAll catch
catchAllCause catchCause
catchAllDefect catchDefect
catchSome catchFilter
catchSomeDefect removed

catchTag, catchTags and catchIf didn’t change, and the course already uses them.

The change that touches server code is underneath. A v3 Cause was a tree with six variants, including Sequential and Parallel. A v4 Cause is a flat list: { reasons: ReadonlyArray<Fail | Die | Interrupt> }.6 The error-logging middleware you’ll write in a later part walks that list instead of recursing:

src/part-1/what-changed.ts
export const logged = findAda.pipe(
Effect.catchCause((cause) => {
for (const reason of cause.reasons) {
if (reason._tag === "Fail") console.error("failed:", reason.error._tag)
if (reason._tag === "Die") console.error("defect:", reason.defect)
}
return Effect.failCause(cause)
}),
)

Fewer things are Effects

In v3 you could yield* an Option, an Either, a Ref, a Deferred or a Fiber inside Effect.gen. In v4 you can’t. None of them are Effects anymore.7 I like the guide’s reason: Effect.all “could accept an array of refs and silently read all of them.”

So you convert on purpose: Effect.fromOption, Effect.fromResult, Ref.get, Deferred.await, Fiber.join. Config and services are still Effects, which is why yield* Users above works.

Inside Effect.gen you write yield* Option.some(id), the way you did in Effect 3. Where does TypeScript put the error?

The error lands on the Effect.gen( call, not on the line that yields. It’s TS2345, and it reads “Generator<Option<string>, …> is not assignable to … Generator<Effect<any, any, any>, …>”. In a long generator, that’s a confusing place to start looking. The repo keeps the mistake on purpose, with a @ts-expect-error on the Effect.gen line so npm run check stays green, and runs it anyway:

src/part-1/option-is-not-an-effect.ts
// @ts-expect-error Option is not an Effect in v4. The error lands here, on Effect.gen
const program: Effect.Effect<string> = Effect.gen(function* () {
const id = yield* Option.some("1")
return id
})
const exit = await Effect.runPromiseExit(program)
console.log(String(exit))
node src/part-1/option-is-not-an-effect.ts
Failure(Cause([Die("Fiber.runLoop: Not a valid effect: some(\"1\")")]))

A defect, not a typed error. If the compiler flags a whole Effect.gen block and you can’t see why, look for a yielded Option or Ref.

The runtime underneath

Forking got clearer names: fork is forkChild and forkDaemon is forkDetach.8 Runtime<R> is gone, and you run with a context through Effect.runForkWith. FiberRef became Context.Reference, with built-ins like References.MinimumLogLevel.9

The one I’d have hit first in a server is layer reuse. In v4, a nested Effect.provide reuses a layer that an enclosing provide already built.10 Here a helper provides Users itself and gets called from a program that already did:

src/part-1/layer-reuse.ts
const nested = program.pipe(Effect.provide(layer))
await Effect.runPromise(nested.pipe(Effect.provide(layer)))
node src/part-1/layer-reuse.ts
building Users

Once. The same shape on 3.22.3 printed it twice. Picture that layer as a connection pool, and v3 quietly opened two. Sibling provides with nothing around them still build their own copy, and Layer.fresh opts out when you want a second one. Composing layers once at the edge is still the better habit. Part 8 is about that.

main provides DbLayer around the whole app. Two route handlers also each do Effect.provide(DbLayer) inside it. How many pools does Effect 4 build?

Effect 4 is also smaller and faster, at least by the announcement’s chart: a minimal program goes from 35.6 kB in v3 to 7.1 kB in v4, throughput from 0.71M to 4.57M tasks per second, and heap for 50,000 fibers from 157.5 MB to 21.8 MB.1 Those are the Effect team’s numbers. I only reproduced the bundle: with esbuild and gzip I got 42.2 kB and 8.8 kB, the same ratio of about 5×. I didn’t measure throughput or memory. On a server the bundle barely matters, but memory per fiber would, since every request runs in one.

You still need runMain

One page of the migration guide is out of date, and it’s the one about keeping the process alive. It says a fiber waiting on Deferred.await keeps Node running in v4, so you don’t need runMain. That mechanism was removed in March, before 4.0 shipped. On 4.0.5 the guide’s own example exits after 10 ms, the same as v3. The only keep-alive left is inside NodeRuntime.runMain. Part 3 shows what it does.

When not to bother

If you run a stable v3 service and nothing new is planned for it, leave it. v3 still gets patches: 3.22.3 came out on October 16, 2026, under the prev tag. The move is worth it the next time you touch the HTTP or platform code, because that’s where most of the import changes are.

The part-1 tag has src/part-1/what-changed.ts, which asserts with @ts-expect-error that every old name above is really gone. If one of them comes back in a later release, npm run check fails.

One name I left out. Effect.fn isn’t new, it’s been there since 3.11, but Effect’s own LLMS.md guide for v4 now makes it the default for reusable functions.

Next in the series: Effect.fn, functions with names and traces.

Footnotes

  1. Sebastian Lorenz, “Effect 4.0”, Effect blog, September 30, 2026. Bundle sizes are minified and gzipped; runtime figures are medians of nine fresh-process runs. ↩ ↩2 ↩3

  2. MIGRATION.md in the Effect repo. The migration guide lives in the repo, not on effect.website. ↩ ↩2 ↩3 ↩4 ↩5

  3. migration/v3-to-v4.md, the import map. ↩

  4. migration/services.md. ↩ ↩2 ↩3

  5. migration/error-handling.md. ↩

  6. migration/cause.md. ↩

  7. migration/yieldable.md. ↩

  8. migration/forking.md. ↩

  9. migration/runtime.md and migration/fiberref.md. ↩

  10. migration/layer-memoization.md. ↩

Piwi hands a single letter to the user at a mailbox; a small note reads no noise.

Get the next one in your inbox

One email when a post goes out, with its sketch. Nothing in between, and one link to leave.

Sign in faster next time?

Add a passkey and skip the email link. Your fingerprint, face or device PIN is enough.