← 报错百科

FiberFailure · Service

这是线索,不是结论。 内容由机器从检索到的中文译文合成,尚未经人确认;引用是提问那一刻的快照, 译文更新后可能过时。每条都附了可点回原文的链接 —— 请核对后再采用。 发现不对请 提 issue

报错原文

(FiberFailure) Error: Service not found: B (defined at <anonymous> (<project>/apps/api/seed-cases/12-provided-wrong-layer.ts:4:32))
    at <project>/node_modules/.pnpm/effect@3.22.2/node_modules/effect/src/internal/fiberRuntime.ts:1112:36
    at <anonymous> (<project>/node_modules/.pnpm/effect@3.22.2/node_modules/effect/src/internal/fiberRuntime.ts:1161:41)
    at body (<project>/node_modules/.pnpm/effect@3.22.2/node_modules/effect/src/Utils.ts:786:14)
    at FiberRuntime.Sync (<project>/node_modules/.pnpm/effect@3.22.2/node_modules/effect/src/internal/fiberRuntime.ts:1161:19)
    at <anonymous> (<project>/node_modules/.pnpm/effect@3.22.2/node_modules/effect/src/internal/fiberRuntime.ts:1398:53)
    at Object.f (<project>/node_modules/.pnpm/effect@3.22.2/node_modules/effect/src/internal/tracer.ts:101:19)
    at FiberRuntime.runLoop (<project>/node_modules/.pnpm/effect@3.22.2/node_modules/effect/src/internal/fiberRuntime.ts:1384:34)

诊断

根据证据,最可能的原因是:该 Effect 依赖 Service `B`,但它拿到的 Layer 并没有提供 `B`(文件名 `12-provided-wrong-layer.ts` 也指向"提供了错误的 Layer"),而 Effect 需要由对应的 Layer 提供其依赖的 Service 才能执行。修复方向:检查 `Effect.provide` 传入的 Layer 是否包含 `B` 的 Layer 定义,以及是否按依赖图顺序把提供 `B` 的 Layer 组合进最终的 Layer。若无法看到你的 Layer 组合代码,请补充最小复现代码(`B` 的 Context.Tag 定义与 Layer 组合部分)以便进一步判断。

依据(3 条站内译文)

你也被这个报错卡住了?

你自己的报错整段贴到报错诊断 —— 它提取的 API 名与类型名来自你的实际代码,比照抄别人的诊断更准; 诊断完也会并进这一条(同一报错算同一条)。

本页来自 2026-09-13 的快照(https://effect-ts.cn)。来自站内 /debug 的真实诊断,按报错签名归并(绝对路径/行列号/堆栈帧已归一)。条目为机器生成、未经人审(reviewed 字段),引用是提问那一刻的快照。