Skip to content
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

Fix handling of sync error in @@asyncDispose #15705

Merged
merged 3 commits into from Jun 19, 2023

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Jun 16, 2023

Q                       A
Fixed Issues?
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

This PR copies two improvements to the dispose helper from TypeScript's implementation (microsoft/TypeScript#54505):

  • for synchronous disposals, we can avoid some recursion and use a loop instead. TS also avoids recursion in the } catch { case, at the expense of an extra closure passed to .then.
  • our handling of synchronous errors in @@asyncDispose was wrong, because we didn't call it in the try block and thus its errors would always hide errors from the block.

@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories Spec: Explicit Resource Management labels Jun 16, 2023
@babel-bot
Copy link
Collaborator

babel-bot commented Jun 16, 2023

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/54669/

@nicolo-ribaudo nicolo-ribaudo merged commit 0679329 into babel:main Jun 19, 2023
54 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the dispose-tail-recursion branch June 19, 2023 06:53
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Sep 19, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories Spec: Explicit Resource Management
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants