-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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: android native rejections should be instanceof Error #44487
fix: android native rejections should be instanceof Error #44487
Conversation
Hi, @javache As in #44051, you suggests that a fix from Java to C++. But I found out that same as fix on iOS #41955, we can treat reject on C++. If we want to fix it from Java, we probably need a Java Error type (currently WritableNativeMap is universal argument for callback), and the argument conversion should support Java Error -> Dynamic -> JSI Object to this specific type. It looks this solution needs huge work. If you have any other ideas, please let me know. |
Base commit: 54f582f |
} | ||
|
||
auto createRejectionError(jsi::Runtime& rt, folly::dynamic args) { | ||
DCHECK(args.size() == 1) << "promise reject should has only one argument"; |
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.
Use react_native_assert
so we get consistent assert handling
return; | ||
} |
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.
nit: make this an else
jsError.asObject(rt).setProperty( | ||
rt, propertyName, valueAsObject.getProperty(rt, propertyName)); |
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.
Cache jsError.asObject
so we don't repeatedly create a new jsi::Value here
|
||
auto propertyNames = valueAsObject.getPropertyNames(rt); | ||
for (size_t i = 0; i < propertyNames.size(rt); ++i) { | ||
auto propertyName = propertyNames.getValueAtIndex(rt, i).asString(rt); |
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.
Wrap in PropNameID.forString() to avoid doing this conversion twice.
Looks good overall, just a few nits |
Thanks for the advice. Changes updated, PTAL again |
@javache has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Hi @javache, is the CI check OK? |
This pull request was successfully merged by huzhanbo.luc in 62cbdbb. When will my fix make it into a release? | How to file a pick request? |
…4487) Summary: fix facebook#44050 ## Changelog: [ANDROID] [FIXED] - fix: android native rejections should be instanceof Error Pull Request resolved: facebook#44487 Test Plan: reject returns Error. Reviewed By: NickGerleman Differential Revision: D57205131 Pulled By: javache fbshipit-source-id: a5950481d0c4909be4dbea0b430e75222258ae68
Summary: fix #44050 ## Changelog: [ANDROID] [FIXED] - fix: android native rejections should be instanceof Error Pull Request resolved: #44487 Test Plan: reject returns Error. Reviewed By: NickGerleman Differential Revision: D57205131 Pulled By: javache fbshipit-source-id: a5950481d0c4909be4dbea0b430e75222258ae68
Summary: fix #44050 ## Changelog: [ANDROID] [FIXED] - fix: android native rejections should be instanceof Error Pull Request resolved: #44487 Test Plan: reject returns Error. Reviewed By: NickGerleman Differential Revision: D57205131 Pulled By: javache fbshipit-source-id: a5950481d0c4909be4dbea0b430e75222258ae68
Summary: fix #44050 ## Changelog: [ANDROID] [FIXED] - fix: android native rejections should be instanceof Error Pull Request resolved: #44487 Test Plan: reject returns Error. Reviewed By: NickGerleman Differential Revision: D57205131 Pulled By: javache fbshipit-source-id: a5950481d0c4909be4dbea0b430e75222258ae68
Summary:
fix #44050
Changelog:
[ANDROID] [FIXED] - fix: android native rejections should be instanceof Error
Test Plan:
reject returns Error.