Skip to content

withAsyncTaskCleanupHandler calls its cleanup handler twice if body throws #80

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

Open
jakepetroules opened this issue Jun 14, 2025 · 0 comments · May be fixed by #81
Open

withAsyncTaskCleanupHandler calls its cleanup handler twice if body throws #80

jakepetroules opened this issue Jun 14, 2025 · 0 comments · May be fixed by #81
Labels
bug Something isn't working

Comments

@jakepetroules
Copy link
Contributor

If the body closure given to withAsyncTaskCleanupHandler throws, its cleanup handler is called twice: once in the catch block where body is called, and then again in the task group task once the Task.sleep throws due to cancellation, which swallows the error and then continues to call the handler as well.

This results in the teardown sequence being invoked twice.

@jakepetroules jakepetroules added the bug Something isn't working label Jun 14, 2025
jakepetroules added a commit that referenced this issue Jun 14, 2025
…hrows

If the body closure given to withAsyncTaskCleanupHandler throws, its cleanup handler is called twice: once in the catch block where body is called, and then again in the task group task once the Task.sleep throws due to cancellation, which swallows the error and then continues to call the handler as well.

This results in the teardown sequence being invoked twice.

Closes #80
jakepetroules added a commit that referenced this issue Jun 14, 2025
…hrows

If the body closure given to withAsyncTaskCleanupHandler throws, its cleanup handler is called twice: once in the catch block where body is called, and then again in the task group task once the Task.sleep throws due to cancellation, which swallows the error and then continues to call the handler as well. That results in the teardown sequence being invoked twice, as well as the teardown sequence being invoked for non-error cases.

This patch ensures the cleanup handler is invoked in failure cases only, and only once.

Closes #80
jakepetroules added a commit that referenced this issue Jun 14, 2025
…hrows

If the body closure given to withAsyncTaskCleanupHandler throws, its cleanup handler is called twice: once in the catch block where body is called, and then again in the task group task once the Task.sleep throws due to cancellation, which swallows the error and then continues to call the handler as well. That results in the teardown sequence being invoked twice, as well as the teardown sequence being invoked for non-error cases.

This patch ensures the cleanup handler is invoked in failure cases only, and only once.

Closes #80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant