Effect CommunityEC
Effect Community16mo ago
80 replies
David Golightly

Propagate errors from child fiber

I have an Effect that uses a FiberHandle:

const DoWork = Effect.gen(function* () {
  return yield* FiberHandle.run(
    handleRef,
    // verified this error gets created
    Effect.tryPromise(...).pipe(Effect.mapError((e) => new CustomError(...)),
  )
})


elsewhere, this is getting invoked:

Effect.gen(function* () {
  if (condition) {
    yield* DoWork
  }
// this is never called
}).pipe(Effect.catchAll((e) => Console.error(e)),


however, the errors that are catchable from within the fiber are not propagated to the parent Effect. This is tracked in the types as well - the type of DoWork is now Effect.Effect<RuntimeFiber<void, CustomError>, never, never> - so the error channel in the parent is
never
.

What's the best way to lift errors from the fiber into the parent Effect?

Thanks again!
Was this page helpful?