Skip to content

Commit c02ae17

Browse files
authored
Fix ParAff apply cancellation (#155)
1 parent ac1fff8 commit c02ae17

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/Effect/Aff.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,9 +775,9 @@ var Aff = function () {
775775
if (tmp) {
776776
tmp = false;
777777
} else if (tail === null) {
778-
join(step, null, null);
778+
join(fail, null, null);
779779
} else {
780-
join(step, tail._1, tail._2);
780+
join(fail, tail._1, tail._2);
781781
}
782782
};
783783
});

test/Test/Main.purs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,26 @@ test_regression_return_fork = assert "regression/return-fork" do
631631
(const (pure unit))
632632
(const (pure true))
633633

634+
test_regression_par_apply_async_canceler Aff Unit
635+
test_regression_par_apply_async_canceler = assert "regression/par-apply-async-canceler" do
636+
ref ← newRef ""
637+
let
638+
action1 = makeAff \_ →
639+
pure $ Canceler \_ → do
640+
delay (Milliseconds 10.0)
641+
void $ modifyRef ref (_ <> "done")
642+
643+
action2 = do
644+
delay (Milliseconds 5.0)
645+
void $ modifyRef ref (_ <> "throw")
646+
throwError (error "Nope.")
647+
648+
catchError
649+
(sequential (parallel action1 *> parallel action2))
650+
\err -> do
651+
val <- readRef ref
652+
pure (val == "throwdone" && message err == "Nope.")
653+
634654
main Effect Unit
635655
main = do
636656
test_pure
@@ -676,3 +696,4 @@ main = do
676696
-- test_scheduler_size
677697
test_parallel_stack
678698
test_regression_return_fork
699+
test_regression_par_apply_async_canceler

0 commit comments

Comments
 (0)