Troubleshooting
Diagnose the most common type and lifecycle failures.
Read the named diagnostic, for example MissingDependencies<Logger | Cache>. The generic
argument is the exact tagged Service instance union that is unavailable. Add those providers to
the Layer, merge the Layers, or use an explicit compatible override for a test.
merge never silently replaces a provider. Use Layer.override(base, replacement) when
replacement is intentional, and ensure same-tag contracts are compatible.
yield* Service needs an active Runtime execution. Run the program through Runtime.run and
keep Service access inside the Effect callback.
Scope.current, yield* Scope, Effect.add and Effect.acquireRelease require an active
Scope. Use a Runtime execution, Scope.run, or Scope.provide with an existing Scope.
Confirm acquisition succeeded, the resource was registered in the current Scope, and the release
callback or disposal protocol is callable. For Effect.add, the object must expose
Symbol.asyncDispose or Symbol.dispose.
Cleanup failures are secondary when the program failed. Configure onCleanupFailure to observe
them. A successful program can surface a cleanup failure because there is no more specific
primary failure.
ExplicitRuntimeContextStorage is a manually managed, sequential strategy from the
better-effect/runtime/explicit subpath. Use it only when the package entrypoint and host can
load it; one instance supports one non-overlapping async flow and rejects concurrent overlap.
The published Runtime entrypoint is officially supported on Node.js and Bun; use its default
storage for concurrent work. This explicit strategy does not make the package generally usable
in browsers, Deno, Cloudflare Workers, or other non-Node hosts, and separate explicit instances
are not a general concurrent-isolation strategy.
The default Hono failure policy redacts every non-Response failure value to
{ error: 'Internal Server Error' } with status 500. An explicitly returned Response failure
is intentionally passed through unchanged. Configure onFailure only when you need a deliberate,
safe domain representation; do not serialize arbitrary exceptions to clients.
Layer generators may yield Service constructors only; their public requirement metadata uses
the corresponding instance types. Use Result.await and Effect.gen for Result operations in
application programs; use Layer.scopedGen for contextual acquisition and cleanup.
A debugging checklist
- Confirm the Service tag is non-empty and stable.
- Inspect
Layer.Provided,Layer.RequiredandLayer.Completewhen a composition root fails to typecheck. - Verify the program runs inside the intended Runtime.
- Check whether the resource belongs to the root Scope or execution Scope.
- Preserve the primary Result/exception and inspect cleanup diagnostics separately.