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 条站内译文)
- 管理 Layer
#intro在管理 Service页面中,你学习了如何创建依赖某个 Service 才能执行的 Effect,以及如何为该 Effect 提供这个 Service。
核验记录 · 英文原文 · 基线a915662 - 管理 Layer
#设计依赖图Config service 提供应用配置。
核验记录 · 英文原文 · 基线a915662 - 管理服务
#intro在编程语境里,服务(service)指的是可以被应用不同部分复用的组件或功能。
核验记录 · 英文原文 · 基线bf46254
你也被这个报错卡住了?
把你自己的报错整段贴到报错诊断 —— 它提取的 API 名与类型名来自你的实际代码,比照抄别人的诊断更准; 诊断完也会并进这一条(同一报错算同一条)。
本页来自 2026-09-13 的快照(https://effect-ts.cn)。来自站内 /debug 的真实诊断,按报错签名归并(绝对路径/行列号/堆栈帧已归一)。条目为机器生成、未经人审(reviewed 字段),引用是提问那一刻的快照。