Skip to content

effect: HttpApi server dies at startup with "TypeError: undefined is not iterable" (logger/fork already work) #6438

Description

@proggeramlug

Summary

An @effect/platform HttpApi server compiles and links cleanly, but dies at startup with TypeError: undefined is not iterable before it ever binds a port. Node serves the same program fine.

This is the last thing between Perry and a working Effect HTTP server: Effect.logInfo, Effect.gen, Effect.fork and Fiber.join all already work natively (see "What already works" below).

Repro

Sources: https://github.com/bjacobso/effect-compiled-experiment

git clone https://github.com/bjacobso/effect-compiled-experiment && cd effect-compiled-experiment
npm install
perry compile src/effect/web.ts -o dist/web
PORT=3111 ./dist/web        # TypeError: undefined is not iterable

src/effect/web.ts is a ~20-line program: HttpLayerRouter.addHttpApi(Api) + NodeHttpServer.layer(createServer, …) + Layer.launch(...).pipe(NodeRuntime.runMain), where Api is an HttpApi.make("Api") with one Schema.Struct success response.

Deps: effect@3.21.4, @effect/platform@0.96.2, @effect/platform-node@0.107.0. perry.compilePackages lists effect + the platform packages (311–371 modules, all compiled native, 0 JS fallback).

Expected vs actual

$ curl http://127.0.0.1:3111/api/health
node : {"ok":true,"service":"perry-effect"}   [HTTP 200]
perry: <no listener>                          [HTTP 000]
       TypeError: undefined is not iterable
           at <anonymous>

The server never starts — the throw happens during layer construction / startup, not per-request.

Environment

  • Perry 889f39eda (v0.5.1258), macOS arm64
  • Coherent full cargo build --release, compiled with auto-optimize (the js_stdlib_init_dispatch no-op-stub warning is absent, so stdlib dispatch is correctly linked — this is not the isolated--p-build trap)

What already works (scoping)

Same repo, same build — these are byte-identical to node --experimental-strip-types:

  • src/effect/logger.tsEffect.logInfo(...).pipe(NodeRuntime.runMain)[HH:MM:SS.mmm] INFO (#0): ...
  • src/effect/forking.tsEffect.gen + Effect.fork + Fiber.join → all three lines, fibers #0/#1, joined result

So the fiber runtime, the pretty logger, generators and forking are all fine. The failure is specific to the HttpApi/layer path.

Diagnostic note

Breaking on js_typeerror_new under lldb does not hit, even though the TypeError is thrown and printed. The auto-optimized build links perry-ext-* staticlibs that bundle their own runtime copy, so the executing throw is a different instance of the symbol than the one lldb binds. Anyone digging in should be aware the obvious breakpoint is misleading — the perry-ext-* staticlib runtime copy is the one to instrument.

undefined is not iterable suggests a destructuring / spread / for…of over an undefined that should be a collection — plausibly a Layer/Context lookup returning undefined where Effect expects an iterable of services.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions