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.ts — Effect.logInfo(...).pipe(NodeRuntime.runMain) → [HH:MM:SS.mmm] INFO (#0): ...
src/effect/forking.ts — Effect.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.
Summary
An
@effect/platformHttpApi server compiles and links cleanly, but dies at startup withTypeError: undefined is not iterablebefore 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.forkandFiber.joinall already work natively (see "What already works" below).Repro
Sources: https://github.com/bjacobso/effect-compiled-experiment
src/effect/web.tsis a ~20-line program:HttpLayerRouter.addHttpApi(Api)+NodeHttpServer.layer(createServer, …)+Layer.launch(...).pipe(NodeRuntime.runMain), whereApiis anHttpApi.make("Api")with oneSchema.Structsuccess response.Deps:
effect@3.21.4,@effect/platform@0.96.2,@effect/platform-node@0.107.0.perry.compilePackageslists effect + the platform packages (311–371 modules, all compiled native, 0 JS fallback).Expected vs actual
The server never starts — the throw happens during layer construction / startup, not per-request.
Environment
889f39eda(v0.5.1258), macOS arm64cargo build --release, compiled with auto-optimize (thejs_stdlib_init_dispatchno-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.ts—Effect.logInfo(...).pipe(NodeRuntime.runMain)→[HH:MM:SS.mmm] INFO (#0): ...src/effect/forking.ts—Effect.gen+Effect.fork+Fiber.join→ all three lines, fibers#0/#1, joined resultSo 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_newunder lldb does not hit, even though the TypeError is thrown and printed. The auto-optimized build linksperry-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 — theperry-ext-*staticlib runtime copy is the one to instrument.undefined is not iterablesuggests a destructuring / spread /for…ofover anundefinedthat should be a collection — plausibly a Layer/Context lookup returningundefinedwhere Effect expects an iterable of services.