-
Notifications
You must be signed in to change notification settings - Fork 65
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
Off-stack error when running parallel action in same execution context #156
Comments
I think the minimal reproduction is test_regression_kill_rethrow ∷ Aff Unit
test_regression_kill_rethrow = assert "regression/par-apply-async-canceler" do
ref ← newRef ""
f1 ← forkAff $ makeAff \k -> k (Left (error "Boom.")) *> mempty
killFiber (error "Nope.") f1 Which throws for me. I would expect this to exit cleanly, where f1 would have "Nope." as it's final exception value. The reason why this is interesting is the "synchronous" resolution of an async action with an exception, followed immediately by a kill. When an async action is fulfilled, the continuation is put into the scheduler. https://github.com/slamdata/purescript-aff/blob/c02ae17e7da8c4df75b824c5b18911931bfe7eba/src/Effect/Aff.js#L324-L336 So this means that async actions are always resolved asynchronously. The I think what's happening is:
So we probably need to guard the scheduled continuation against the interrupt state. |
Changing the above to step = runAsync(util.left, step._1, function (result) {
return function () {
if (runTick !== localRunTick) {
return;
}
runTick++;
var currentInterrupt = interrupt;
Scheduler.enqueue(function () {
if (interrupt !== currentInterrupt) {
return;
}
status = STEP_RESULT;
step = result;
run(runTick);
});
};
}); Fixes the issue for me, but there might be a better way to do the check. |
So, for some reason, when killing a fiber that has thrown an error inside a parallel action (and executed via
sequential
) that is immune to errors viatry
, the killing of the fiber causes an off-stack error to be produced. Breaking the execution context usingdelay
will have the error go away. Similarly, not usingsequential $ parallel
at all will also make the error go away. Note that the error only surfaces when killing the fiber, and that you have to wait a little before the program terminates to witness the off-stack error.The text was updated successfully, but these errors were encountered: