Skip to content

Commit

Permalink
Fix ParAff apply cancellation (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
natefaubion authored Jul 12, 2018
1 parent ac1fff8 commit c02ae17
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Effect/Aff.js
Original file line number Diff line number Diff line change
Expand Up @@ -775,9 +775,9 @@ var Aff = function () {
if (tmp) {
tmp = false;
} else if (tail === null) {
join(step, null, null);
join(fail, null, null);
} else {
join(step, tail._1, tail._2);
join(fail, tail._1, tail._2);
}
};
});
Expand Down
21 changes: 21 additions & 0 deletions test/Test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,26 @@ test_regression_return_fork = assert "regression/return-fork" do
(const (pure unit))
(const (pure true))

test_regression_par_apply_async_canceler Aff Unit
test_regression_par_apply_async_canceler = assert "regression/par-apply-async-canceler" do
ref ← newRef ""
let
action1 = makeAff \_ →
pure $ Canceler \_ → do
delay (Milliseconds 10.0)
void $ modifyRef ref (_ <> "done")

action2 = do
delay (Milliseconds 5.0)
void $ modifyRef ref (_ <> "throw")
throwError (error "Nope.")

catchError
(sequential (parallel action1 *> parallel action2))
\err -> do
val <- readRef ref
pure (val == "throwdone" && message err == "Nope.")

main Effect Unit
main = do
test_pure
Expand Down Expand Up @@ -676,3 +696,4 @@ main = do
-- test_scheduler_size
test_parallel_stack
test_regression_return_fork
test_regression_par_apply_async_canceler

0 comments on commit c02ae17

Please sign in to comment.