evilsoft / crocks

A collection of well known Algebraic Data Types for your utter enjoyment.
https://crocks.dev
ISC License
1.59k stars 102 forks source link

Async 'race' and 'all' cancellation after first rejection #519

Open dartheian opened 3 years ago

dartheian commented 3 years ago

Running the following script in deno exits the job after 5 seconds, suggesting the first Async (the one resolving in 'OK') keeps running even after the second Async has been rejected:

import crocks from 'https://cdn.skypack.dev/crocks'
const {Async} = crocks

const test = Async.resolveAfter(5000, 'OK').race(Async.rejectAfter(1000, 'TIMEOUT'))

test.fork(console.log, console.log)

A similar behavior happens with Async.all: when a computation is rejected, all the remaining keep going. Is this the intended behavior? I expect all the remaining computations to be cancelled and the cleanup functions to be executed after a single Aync has been rejected.