Effect CommunityEC
Effect Community2y ago
13 replies
schniz

Issue with Effect.uninterruptible and Fiber.await in effect-ts

Hello! wrt Effect.uninterruptible, it seems that when I fork an Effect, I can't wait for it to finish even if it's uninterruptible:

import { Effect, Fiber } from "effect"

const sleepAndLog = Effect.gen(function*(_) {
  yield* Effect.sleep("100 millis");
  yield* Effect.logInfo("hi");
}).pipe(Effect.uninterruptible);

Effect.gen(function* () {
  const fiber = yield* Effect.fork(sleepAndLog);
  yield* Fiber.interrupt(fiber)
  yield* Fiber.await(fiber); // not working
  // we want to see "hi"
}).pipe(Effect.runPromise)


does it make sense? Should I do something else? I know that I can probably use a deferred or something but based on the JSDocs it seems like it should work: "the effect will resume when the fiber exits" -- and i assumed that the fiber will exit once the Effect is done as its uninterruptible
Was this page helpful?