报错百科 机器生成 · 未经人审

Effect 的类型报错又长又难读,而且搜不到——官方文档不收录报错, 英文社区也很少有人愿意贴这么长的输出。这一页把站内诊断过的报错按 报错签名归并起来(同一个报错在不同机器上路径、行列号、堆栈都不同, 但底层是同一个问题),让它变成可搜索、可链接、可累积的东西。

请按"线索"而不是"结论"来用它。条目由机器从检索到的中文译文合成, 尚未经人确认;引用是提问那一刻的快照,译文更新后可能过时 —— 所以每条都附了可点回原文的链接, 建议核对后再采用。发现结论不对,欢迎 提 issue,那正是让它变准的方式。

共 8 条签名,按被问次数排序(快照截至 )。

FiberFailure · Operation · TimeoutException

被问到 2 最近 5 天前 机器生成 · 未经人审 nocode-1jl6upc

(FiberFailure) Error: TimeoutException: Operation timed out after '50ms'

最可能的原因:某个 Effect 被 Effect.timeout 置于 50ms 的时长内竞速,而它没能在该时长内完成,于是以类型化的 Cause.TimeoutError(TimeoutException)失败,并由 FiberFailure 抛出(证据 1、2)。 修复方向:放宽时间窗口,或对属于临时性失败的操作改用重试(如临时的网络/服务不可用场景),并显式处理超时这个类型化错误而不是让它逃逸(证据 2、3)。若要把超时归因到具体某个 Effect 调用,请补充包含 Effect.timeout 及其包裹

TS2345 · Effect

被问到 2 最近 5 天前 机器生成 · 未经人审 ts2345-iw0q9q

src/app.ts(12,5): error TS2345: Argument of type 'Effect<number, never, never>' is not assignable to parameter of type 'number'. Did you mean to call Effect.runPromise?
  at /Users/bob/proj/node_modules/effect/src/Effect.ts:5:1

最可能的原因:第 5 行把 `Effect` 值本身当成了普通参数传入,而该位置期望 `number`;`Effect` 只是对计算的描述而非计算结果,所以类型不匹配(错误提示里的 `Effect.runPromise` 只是 TS 的猜测,别直接照做)。修复方向:确认该参数是否应传真实数值——若是,就把产生该数值的计算改为在当前流程内组合(如用 `Effect.map`/`Effect.flatMap` 等)而不是把 `Effect` 直接递给期望 `number` 的形参;若确实需要把它跑出结果,只能用 `Ef

FiberFailure · TypeError

被问到 1 最近 5 天前 机器生成 · 未经人审 nocode-paz6w9

(FiberFailure) TypeError: yield* (intermediate value) is not iterable
    at <anonymous> (<project>/apps/api/seed-cases/15-yield-non-effect.ts:4:59)

最可能的原因:在 `Effect.gen` 的 generator 函数里,`yield*` 的对象不是一个 Effect(比如是普通值、Promise 或其它不可迭代的值),所以运行时抛出 `is not iterable`,这与第 4 行的 `yield*` 表达式直接对应。 修复方向:确保 `yield*` 后面始终是 Effect——纯值用 `Effect.succeed`、Promise 用 `Effect.promise`/`Effect.tryPromise` 包起来,或者对纯值直接 `return

AsyncFiberException · Fiber · FiberFailure

被问到 1 最近 5 天前 机器生成 · 未经人审 nocode-1dozdil

[AsyncFiberException: Fiber #0 cannot be resolved synchronously. This is caused by using runSync on an effect that performs async work] {
  name: '(FiberFailure) AsyncFiberException',
  Symbol(effect/Runtime/FiberFailure): Symbol(effect/Runtime/FiberFailure),
  Symbol(effect/Runtime/FiberFailure/Cause): {
    _tag: 'Die',
    defect: [Fiber #0 cannot be resolved synchronously. This is caused by us

根据文档,`runSync` 只能同步执行 Effect,当目标 Effect 内部包含异步工作时就无法同步求值,于是抛出 `AsyncFiberException`(对应 `effect/Cause/AsyncFiberException`)。 修复方向:不要用 `runSync` 运行含异步工作的 Effect,改用 Effect 模块中其他能等待异步完成的 `run` 函数。 若不确定是哪段 Effect 触发了异步,请提供最小复现代码。

FiberFailure · Service

被问到 1 最近 5 天前 机器生成 · 未经人审 nocode-2k2i3y

(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/.pnp

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

Cache · FiberFailure · Service

被问到 1 最近 5 天前 机器生成 · 未经人审 nocode-hxx0cu

(FiberFailure) Error: Service not found: Cache (defined at <anonymous> (<project>/apps/api/seed-cases/11-service-not-found.ts:9:40))
    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/.pn

最可能的原因:这个 Effect(或其依赖链)需要 `Cache` 这个 Service,但运行时没有为它提供对应的 Layer,于是 Effect 的 requirements 未被满足,抛出 `Service not found: Cache`(证据 1 正是这种情况的反面:Effect 依赖某 Service 时,必须为该 Effect 提供这个 Service)。 修复方向:检查构建 Effect 的地方,确认提供 `Cache` 的 Layer 已通过 Layer 组合/提供的方式真正接入了这条执行链(

TS2345 · Config · Db · Effect

被问到 1 最近 5 天前 机器生成 · 未经人审 ts2345-hv420z

seed-cases/06-runpromise-missing-many.ts(10,38): error TS2345: Argument of type 'Effect<string, never, Config | Logger | Db>' is not assignable to parameter of type 'Effect<string, never, never>'.
  Type 'Config | Logger | Db' is not assignable to type 'never'.
    Type 'Config' is not assignable to type 'never'.

最可能的原因:`runPromise` 要求 Effect 的 R 参数为 `never`,而这里的 Effect 仍然声明了未满足的依赖 `Config | Logger | Db`,也就是你还没有把对应 service 的 Layer 提供给它(文档指出 Logger service 本身还依赖 Config service 来取配置)。 修复方向:先用 `Layer` 把这些 service(含 Logger 所依赖的 Config)组合好,通过 `Effect.provide` 传给该 Effect,使

AsyncFiberException · Fiber · FiberFailure

被问到 1 最近 5 天前 机器生成 · 未经人审 nocode-1gmhi86

(FiberFailure) Error: AsyncFiberException: Fiber #0 cannot be resolved synchronously

最可能的原因:你对一个包含异步操作的 Effect 使用了同步的 run 函数(如 `runSync` 一类),导致该 Fiber 无法同步完成,从而抛出 `AsyncFiberException`。修复方向:不要用同步 run 变体去执行含异步步骤的 Effect,改用面向异步 Effect 的 run 函数,或先把异步部分在 Effect 内部组合好再运行。现有证据只说明 Effect 模块提供了多种 run 函数,若仍无法解决,请补充最小复现代码(具体用了哪个 run 函数、Effect 内是否有异步操作)。

没有找到你的报错?把报错整段贴到报错诊断,诊断完它就会进这里 (下次导出后进入静态快照)。