Sitelet https://github.com/purescript-contrib/purescript-aff/pull/161
Skip to content

Fix finalization after failure - #161

Merged
natefaubion merged 2 commits into
purescript-contrib:masterfrom
natefaubion:fix-bracket-catch
Aug 24, 2018
Merged

natefaubion merged 2 commits into
purescript-contrib:masterfrom
natefaubion:fix-bracket-catch

Conversation

@natefaubion

Copy link
Copy Markdown
Collaborator

It appears to have only worked coincidentally before. When the
interpreter enters into a finalization block, it puts a Finalized node
onto the attempt stack with the current step. However if there was
a failure, then step would be null. It "worked" before because there was
stale state, and fail could be preserved through finalization. This
bug was exposed by using catchError within the finalization block,
which resets the failure state to null. Thus when it resumes after
finalization, both step and fail are null, which is an invalid
state. The solution is to preserve fail in addition to step in
a Finalized node.

Fixes #159

It appears to have only worked coincidentaly before. When the
interpreter enters into a finalization block, it puts a `Finalized` node
onto the attempt stack with the current `step`. However if there was
a failure, then step would be null. It "worked" before because there was
stale state, and `fail` could be preserved through finalization. This
bug was exposed by using `catchError` within the finalization block,
which resets the failure state to null. Thus when it resumes after
finalization, both `step` and `fail` are null, which is an invalid
state. The solution is to preserve `fail` in addition to `step` in
a `Finalized` node.
@natefaubion

Copy link
Copy Markdown
Collaborator Author

@felixSchl Can you confirm this fixes your issue?

I have a suspicion that there are other bugs caused by this sort of state falling through, but I can merge this and investigate that in a follow up PR.

@felixSchl

Copy link
Copy Markdown

Hey, sorry for the delay. It does indeed appear to fix the problem 👍

@natefaubion
natefaubion merged commit 5450756 into purescript-contrib:master Aug 24, 2018
@natefaubion
natefaubion deleted the fix-bracket-catch branch August 24, 2018 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants