Effect CommunityEC
Effect Community3y ago
12 replies
antoine-coulon

Concurrency Issue with @effect-ts/core Library

Hello everyone, I'm facing a weird behavior when running some operations concurrently. In that case I'm using @effect-ts/core but I'm not able to reproduce the behavior when using a simpler version of my use case, so I know it's not a runtime bug.

I have a list of Effects that are run concurrently using collectAllPar and each Effect is raced with a dedicated timer (Effect that timeout after 5s) such as:

T.collectAllPar([
  T.timeout(5000)(someAsyncComputation1),
  T.timeout(5000)(someAsyncComputation2),
  T.timeout(5000)(someAsyncComputation3)
]);


For some reason, it appears that sometimes not all operations someAsyncComputation are started, for example:

- someAsyncComputation1 triggered
- someAsyncComputation2 triggered

But someAsyncComputation3 is never started.

Also, someAsyncComputation are using another runtime instance created (only once) to run the Effects:

// Somewhere
const runtime = T.runtime<R>();

// And after
const someAsyncComputation = pipe(
  runtime,
  T.chain((runtime) => T.promise(() => runtime.runPromise(computation))
)


So my question is what could conceptually prevents/blocks someAsyncComputation to be started in that case?
I'm aware that the Effect returned by T.timeout waits for the underlying Effect to be fully interrupted before returning but in that case there is no blocking release action

As a quick note there is normally I/O blocking operation done by computation that could potentially block the event loop (from what I could see in the Azure SDK)
Was this page helpful?