Skip to content

Fix ParAff apply cancellation #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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