Skip to content

Commit

Permalink
Check if step has changed since since enqueuing RELEASE
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Schlitter committed May 21, 2019
1 parent 82a0810 commit b206d08
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Effect/Aff.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ var Aff = function () {
result = util.fromRight(step);
// We need to enqueue the Release with the same interrupt
// status as the Bracket that is initiating it.
attempts = new Aff(CONS, new Aff(RELEASE, attempt._2, result), attempts, tmp);
attempts = new Aff(CONS, new Aff(RELEASE, attempt._2, step), attempts, tmp);
// We should only coninue as long as the interrupt status has not changed or
// we are currently within a non-interruptable finalizer.
if (interrupt === tmp || bracketCount > 0) {
Expand All @@ -474,16 +474,17 @@ var Aff = function () {
// since we enqueued the item, and the bracket count is 0. If the
// bracket count is non-zero then we are in a masked state so it's
// impossible to be killed.
var v = util.fromRight(attempt._2);
if (interrupt && interrupt !== tmp && bracketCount === 0) {
if (step == null || util.isLeft(step)) {
step = attempt._1.killed(util.fromLeft(interrupt))(attempt._2);
if (step == attempt._2 || step == null || util.isLeft(step)) {
step = attempt._1.killed(util.fromLeft(interrupt))(v);
} else {
step = attempt._1.completed(util.fromRight(step))(attempt._2);
step = attempt._1.completed(util.fromRight(step))(v);
}
} else if (fail) {
step = attempt._1.failed(util.fromLeft(fail))(attempt._2);
step = attempt._1.failed(util.fromLeft(fail))(v);
} else {
step = attempt._1.completed(util.fromRight(step))(attempt._2);
step = attempt._1.completed(util.fromRight(step))(v);
}
fail = null;
bracketCount++;
Expand Down

0 comments on commit b206d08

Please sign in to comment.