# What changed in Effect 4 when you build a backend

- Published: 2026-11-08
- Updated: 2026-11-26
- Tags: Effect on the Backend, Effect, TypeScript
- URL: https://devtrillo.com/writing/effect-backend-1-what-changed-in-effect-4/

> 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](/writing/learning-effect-1-introduction/) stops. The code lives in [devtrillo/effect-on-the-backend](https://github.com/devtrillo/effect-on-the-backend/tree/part-1), and every part is a tag.

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

```text title="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](/writing/learning-effect-8-services-without-the-ceremony/), `Effect.catch` (Effect 3 called it `catchAll`) is in [part 6](/writing/learning-effect-6-catch-one-error-not-the-world/), and `AsyncFiberError` is in [part 9](/writing/learning-effect-9-run-effects-at-the-edge/). 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."[^announce] 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.[^migration] This is what a clean install of `@effect/platform-node` took on Effect 3. It isn't from the series repo:

```json title="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:

```json title="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`."[^migration] 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.[^announce] A server you'll run for years cares about that. A script doesn't.

**Quiz:** 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?

- effect and @effect/platform-node, both 4.0.5. HTTP and SQL are imported from effect/http and effect/sql.
- The same four packages, all bumped to 4.0.5
- effect at 4.0.5, the other three left on their 0.x versions

**Answer:** effect and @effect/platform-node, both 4.0.5. HTTP and SQL are imported from effect/http and effect/sql. — @effect/platform and @effect/sql merged into effect. Only runtime and driver packages stay separate, and they share effect's version.

- Not "The same four packages, all bumped to 4.0.5": @effect/platform has no 4.x release. Its latest is still 0.97.2, which peers on effect 3.
- Not "effect at 4.0.5, the other three left on their 0.x versions": npm refuses with ERESOLVE. The 0.x packages all peer on effect ^3.

## Where things moved

The modules didn't disappear. They moved under `effect/`, and there are no compatibility exports for the old paths.[^migration] These are the ones a server touches:[^imports]

| 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."[^migration]

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.[^migration] 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."[^services] 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:

**Morph the Effect 3 Users service into Effect 4**

Before:

```ts
export class Users extends Effect.Service<Users>()("Users", {
  effect: make,
}) {}

// Users.Default was generated for you
```

After:

```ts
export class Users extends Context.Service<Users>()("Users", { make }) {
  static readonly layer = Layer.effect(this, this.make)
}
```

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.[^services] 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.[^services] 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:

```ts title="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:[^errors]

| 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> }`.[^cause] The error-logging middleware you'll write in a later part walks that list instead of recursing:

```ts title="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.[^yieldable] 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.

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

- On the Effect.gen( line
- On the yield* line
- Nowhere. It fails at runtime with NoSuchElementError

**Answer:** On the Effect.gen( line — The generator's yield type no longer matches what Effect.gen accepts, so the mismatch is reported at the call. Use Effect.fromOption.

- Not "On the yield* line": That's where you'd look first. But yielding an Option is fine for a generator; it's the generator as a whole that Effect.gen rejects.
- Not "Nowhere. It fails at runtime with NoSuchElementError": That's close to what v3 did for a None. In v4 it's a type error, and if you force it past the compiler it dies instead.

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:

```ts title="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))
```

```text title="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`.[^forking] `Runtime<R>` is gone, and you run with a context through `Effect.runForkWith`. `FiberRef` became `Context.Reference`, with built-ins like `References.MinimumLogLevel`.[^runtime]

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.[^memo] Here a helper provides `Users` itself and gets called from a program that already did:

```ts title="src/part-1/layer-reuse.ts"
const nested = program.pipe(Effect.provide(layer))
await Effect.runPromise(nested.pipe(Effect.provide(layer)))
```

```text title="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.

**Quiz:** 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?

- One
- Two, one per handler
- Three

**Answer:** One — Both handler provides are nested inside main's, and main already built DbLayer, so they reuse it. Effect 3 would build three.

- Not "Two, one per handler": That's what you get with no provide around them. Siblings on their own each build a copy.
- Not "Three": That was Effect 3. Use Layer.fresh if you really want separate instances.

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.[^announce] 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](https://github.com/Effect-TS/effect/commit/3cfadc458b070c6cba6c5674b72a059f1e49118b), 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](https://github.com/devtrillo/effect-on-the-backend/tree/part-1) 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](https://github.com/Effect-TS/effect/blob/effect@4.0.5/LLMS.md) for v4 now makes it the default for reusable functions.

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

[^announce]: Sebastian Lorenz, ["Effect 4.0"](https://effect.website/blog/releases/effect/40), Effect blog, September 30, 2026. Bundle sizes are minified and gzipped; runtime figures are medians of nine fresh-process runs.

[^migration]: [`MIGRATION.md`](https://github.com/Effect-TS/effect/blob/main/MIGRATION.md) in the Effect repo. The migration guide lives in the repo, not on effect.website.

[^imports]: [`migration/v3-to-v4.md`](https://github.com/Effect-TS/effect/blob/main/migration/v3-to-v4.md), the import map.

[^services]: [`migration/services.md`](https://github.com/Effect-TS/effect/blob/main/migration/services.md).

[^errors]: [`migration/error-handling.md`](https://github.com/Effect-TS/effect/blob/main/migration/error-handling.md).

[^cause]: [`migration/cause.md`](https://github.com/Effect-TS/effect/blob/main/migration/cause.md).

[^yieldable]: [`migration/yieldable.md`](https://github.com/Effect-TS/effect/blob/main/migration/yieldable.md).

[^forking]: [`migration/forking.md`](https://github.com/Effect-TS/effect/blob/main/migration/forking.md).

[^runtime]: [`migration/runtime.md`](https://github.com/Effect-TS/effect/blob/main/migration/runtime.md) and [`migration/fiberref.md`](https://github.com/Effect-TS/effect/blob/main/migration/fiberref.md).

[^memo]: [`migration/layer-memoization.md`](https://github.com/Effect-TS/effect/blob/main/migration/layer-memoization.md).

- **Part 2 — Effect.fn: functions with names and traces**: named functions that keep their callers in stack traces, open spans on their own, and run your error handling inside the span.
