Skip to content

Don't resume from an enqueued task if interrupted #162

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
6 changes: 6 additions & 0 deletions src/Effect/Aff.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ var Aff = function () {
}
runTick++;
Scheduler.enqueue(function () {
// It's possible to interrupt the fiber between enqueuing and
// resuming, so we need to check that the runTick is still
// valid.
if (runTick !== localRunTick + 1) {
return;
}
status = STEP_RESULT;
step = result;
run(runTick);
Expand Down
8 changes: 8 additions & 0 deletions test/Test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,13 @@ test_regression_bracket_catch_cleanup = assert "regression/bracket-catch-cleanup
(\_ → throwError (error "Nope."))
pure $ lmap message res == Left "Nope."

test_regression_kill_sync_async ∷ Aff Unit
test_regression_kill_sync_async = assert "regression/kill-sync-async" do
ref ← newRef ""
f1 ← forkAff $ makeAff \k -> k (Left (error "Boom.")) *> mempty
killFiber (error "Nope.") f1
pure true

main ∷ Effect Unit
main = do
test_pure
Expand Down Expand Up @@ -707,3 +714,4 @@ main = do
test_regression_return_fork
test_regression_par_apply_async_canceler
test_regression_bracket_catch_cleanup
test_regression_kill_sync_async