From b5240af07c7af52f7a32c976a0618a244dfa0e24 Mon Sep 17 00:00:00 2001 From: Nathan Faubion Date: Mon, 25 Mar 2019 11:43:45 -0700 Subject: [PATCH] Fix supervision when no child filbers are active (#164) * Fix supervision when no child filbers are active * Fix callback reference --- src/Effect/Aff.js | 4 ++++ test/Test/Main.purs | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/Effect/Aff.js b/src/Effect/Aff.js index ff8bca2..63a38e7 100644 --- a/src/Effect/Aff.js +++ b/src/Effect/Aff.js @@ -169,6 +169,10 @@ var Aff = function () { }, killAll: function (killError, cb) { return function () { + if (count === 0) { + return cb(); + } + var killCount = 0; var kills = {}; diff --git a/test/Test/Main.purs b/test/Test/Main.purs index 4f70574..451c6cc 100644 --- a/test/Test/Main.purs +++ b/test/Test/Main.purs @@ -667,6 +667,14 @@ test_regression_kill_sync_async = assert "regression/kill-sync-async" do killFiber (error "Nope.") f1 pure true +test_regression_kill_empty_supervisor ∷ Aff Unit +test_regression_kill_empty_supervisor = assert "regression/kill-empty-supervisor" do + f1 ← forkAff $ supervise $ delay $ Milliseconds 10.0 + let + a = parallel $ killFiber (error "Nope.") f1 $> true + b = parallel $ delay (Milliseconds 20.0) $> false + sequential (a <|> b) + main ∷ Effect Unit main = do test_pure @@ -715,3 +723,4 @@ main = do test_regression_par_apply_async_canceler test_regression_bracket_catch_cleanup test_regression_kill_sync_async + test_regression_kill_empty_supervisor