-
Notifications
You must be signed in to change notification settings - Fork 4.5k
iAPI: Fix captured errors in withScope
generators
#70303
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
Conversation
Size Change: +28 B (0%) Total Size: 1.85 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but can you add an entry to the changelog?
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
f5e7d6e
to
9f9105a
Compare
@luisherranz, changelog updated! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks David!
* Add failing test * Fix error handling in withScope generator * Allow generators to throw * Throw for returned rejected promises * Add unit tests for withScope * Remove duplicated tests * Update changelog Co-authored-by: DAreRodz <darerodz@git.wordpress.org> Co-authored-by: luisherranz <luisherranz@git.wordpress.org>
What?
This PR fixes an issue in the
withScope
function when it creates wrappers around async actions and callbacks defined in a store. In particular, the wrapper passes the wrong value to the generator in ayield
operator that appears after an error is caught.Also, other fixes related to errors have been addressed:
next
orthrow
functions are called and they throw an error. This is the equivalent of an uncaught error in the generator's code.return
) is a rejected promise, similar to async functions.Why?
Async functions in the store should properly allow error handling.
Testing Instructions
E2E and unit tests have been added.