Bug: error in finally during halt propagates despite being caught#1128
Open
taras wants to merge 1 commit intothefrontside:v4from
Open
Bug: error in finally during halt propagates despite being caught#1128taras wants to merge 1 commit intothefrontside:v4from
taras wants to merge 1 commit intothefrontside:v4from
Conversation
When a child task throws in a finally block during halt, the error propagates through two independent paths: (1) through halt() return, which the caller can catch, and (2) through the scope tree, which fails the parent scope unconditionally. This means even when the caller explicitly catches the error from yield* task.halt(), the parent scope is still considered failed. This test demonstrates the bug by spawning a child that throws in finally during halt, catching the error via try/catch around yield* task.halt(), and asserting the parent resolves with 'success'.
commit: |
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.
Motivation
When a child task throws in a
finallyblock during halt, the error propagates through two independent paths:halt()return — the caller'stry/catchcatches it ✓This means even when the caller explicitly handles the error from
yield* task.halt(), the parent scope is still considered failed and the error escapes.All three variants reproduce: synchronous
throw, synchronousactionreject, and asyncuntil(Promise.reject(...)).Approach
This PR adds a single failing test to
test/spawn.test.tsthat demonstrates the bug. No fix is included — this is intended to document the issue and serve as a regression test for a future fix.