fix: Unmask exceptions in listener retries#4615
Merged
steve-chavez merged 1 commit intoPostgREST:mainfrom Jan 28, 2026
Merged
Conversation
0adc283 to
6a8b7d8
Compare
0ec31f5 to
ab47d94
Compare
src/PostgREST/Listener.hs
Outdated
Comment on lines
+64
to
+65
| -- TODO is masking really necessary here? We unmask the onError handler anyway... | ||
| void $ mask $ \unmask -> handle (unmask . onError) $ unmask $ do |
Member
There was a problem hiding this comment.
Right, I was thinking the same.. can we avoid the mask/unmask?
FWIW, forkFinally code is simple:
forkFinally :: IO a -> (Either SomeException a -> IO ()) -> IO ThreadId
forkFinally action and_then =
mask $ \restore ->
forkIO $ try (restore action) >>= and_then
Collaborator
Author
There was a problem hiding this comment.
Right, I was thinking the same.. can we avoid the mask/unmask?
Fixed.
I've also changed return type of retryingListen to IO Void to make sure no accidental loop exit happens.
Updated changeling as well and I think it is now in a committable shape.
Member
There was a problem hiding this comment.
Nice! forever also makes the code look much clearer 💯
00c9526 to
a08908c
Compare
forkFinally calls error handler with exceptions masked. Our handleFinally does not restore exception state before calling retryingListener so after first error the whole listener is running with exceptions masked. This patch ensures handleFinally is run with exceptions unmasked.
a08908c to
474a959
Compare
steve-chavez
approved these changes
Jan 28, 2026
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin v14
git worktree add -d .worktree/backport-4615-to-v14 origin/v14
cd .worktree/backport-4615-to-v14
git switch --create backport-4615-to-v14
git cherry-pick -x 73a465501e9574fbd77505fb807a461392f3c52e |
Member
Member
|
Fixed the conflict and pushed in 16c7671 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
forkFinally calls error handler with exceptions masked. Our handleFinally does not restore exception state before calling retryingListener so after first error the whole listener is running with exceptions masked.
This patch ensures handleFinally is run with exceptions unmasked.