-
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
[android] Allow 'userInfo' for native promise.reject + add native error stack support #20940
Closed
Salakar
wants to merge
12
commits into
facebook:master
from
invertase:android-promise-reject-userinfo
Closed
[android] Allow 'userInfo' for native promise.reject + add native error stack support #20940
Salakar
wants to merge
12
commits into
facebook:master
from
invertase:android-promise-reject-userinfo
Conversation
This file contains 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
…to be passed to reject
…ap instance to be passed to reject
…ary and not done anywhere else - prevents a 'ambiguous method' error as rejects 3rd arg can be Throwable or Writable map.
Cleanup to match the interface and additionally adds support/fixes for `TODO(8850038)`
Updated to match `PromiseImpl` changes.
facebook-github-bot
added
the
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
label
Sep 1, 2018
This was referenced Sep 1, 2018
hey99xx
reviewed
Sep 14, 2018
… cause an `IndexOutOfBounds` exception
@dulmandakh would you mind reviewing this PR? It seems it's right up your alley |
28 tasks
Generated by 🚫 dangerJS |
facebook-github-bot
added
the
Import Started
This pull request has been imported. This does not imply the PR has been approved.
label
Dec 11, 2018
facebook-github-bot
approved these changes
Dec 11, 2018
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.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
grabbou
pushed a commit
that referenced
this pull request
Dec 17, 2018
…upport (#20940) Summary: As mentioned [here](react-native-community/releases#34 (comment)), Android is missing native Promise reject with a `userInfo` `WritableMap` support and also `nativeStack` support (which addresses `TODO(8850038)`). This PR adds Android support for both of these. React Native on iOS ([here](https://github.com/facebook/react-native/blob/master/React/Base/RCTUtils.m#L433)) and Windows ([here](microsoft/react-native-windows#732)) already support this so this is a relatively minor addition to bring Android in line with the other platforms. (JS support is also [here](https://github.com/facebook/react-native/blob/master/Libraries/BatchedBridge/NativeModules.js#L145-L148)) Existing methods remain unchanged other than general cleanup of variable names (`e -> throwable`) and adding code comments/docs. Additionally, the `ShareTestModule` implementation of Promise (SimplePromise) was updated to reflect these changes - other line changes in this file are from formatting in Android Studio - if this is an issue let me know. - Currently inconsistent with other platforms. - Blocking a couple of issues over at [invertase/react-native-firebase](https://github.com/invertase/react-native-firebase) - save for re-writing everything to Promise resolve only - which is no small change and isn't a great solution either. Pull Request resolved: #20940 Differential Revision: D13412527 Pulled By: cpojer fbshipit-source-id: 2ca6c5f3db9ff2c2986b02edda80bc73432f66d3
hramos
removed
Import Started
This pull request has been imported. This does not imply the PR has been approved.
labels
Feb 6, 2019
matt-oakes
pushed a commit
to matt-oakes/react-native
that referenced
this pull request
Feb 7, 2019
…upport (facebook#20940) Summary: As mentioned [here](react-native-community/releases#34 (comment)), Android is missing native Promise reject with a `userInfo` `WritableMap` support and also `nativeStack` support (which addresses `TODO(8850038)`). This PR adds Android support for both of these. React Native on iOS ([here](https://github.com/facebook/react-native/blob/master/React/Base/RCTUtils.m#L433)) and Windows ([here](microsoft/react-native-windows#732)) already support this so this is a relatively minor addition to bring Android in line with the other platforms. (JS support is also [here](https://github.com/facebook/react-native/blob/master/Libraries/BatchedBridge/NativeModules.js#L145-L148)) Existing methods remain unchanged other than general cleanup of variable names (`e -> throwable`) and adding code comments/docs. Additionally, the `ShareTestModule` implementation of Promise (SimplePromise) was updated to reflect these changes - other line changes in this file are from formatting in Android Studio - if this is an issue let me know. - Currently inconsistent with other platforms. - Blocking a couple of issues over at [invertase/react-native-firebase](https://github.com/invertase/react-native-firebase) - save for re-writing everything to Promise resolve only - which is no small change and isn't a great solution either. Pull Request resolved: facebook#20940 Differential Revision: D13412527 Pulled By: cpojer fbshipit-source-id: 2ca6c5f3db9ff2c2986b02edda80bc73432f66d3
t-nanava
pushed a commit
to microsoft/react-native-macos
that referenced
this pull request
Jun 17, 2019
…upport (facebook#20940) Summary: As mentioned [here](react-native-community/releases#34 (comment)), Android is missing native Promise reject with a `userInfo` `WritableMap` support and also `nativeStack` support (which addresses `TODO(8850038)`). This PR adds Android support for both of these. React Native on iOS ([here](https://github.com/facebook/react-native/blob/master/React/Base/RCTUtils.m#L433)) and Windows ([here](microsoft/react-native-windows#732)) already support this so this is a relatively minor addition to bring Android in line with the other platforms. (JS support is also [here](https://github.com/facebook/react-native/blob/master/Libraries/BatchedBridge/NativeModules.js#L145-L148)) Existing methods remain unchanged other than general cleanup of variable names (`e -> throwable`) and adding code comments/docs. Additionally, the `ShareTestModule` implementation of Promise (SimplePromise) was updated to reflect these changes - other line changes in this file are from formatting in Android Studio - if this is an issue let me know. - Currently inconsistent with other platforms. - Blocking a couple of issues over at [invertase/react-native-firebase](https://github.com/invertase/react-native-firebase) - save for re-writing everything to Promise resolve only - which is no small change and isn't a great solution either. Pull Request resolved: facebook#20940 Differential Revision: D13412527 Pulled By: cpojer fbshipit-source-id: 2ca6c5f3db9ff2c2986b02edda80bc73432f66d3
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Merged
This PR has been merged.
Platform: Android
Android applications.
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.
Changes
As mentioned here, Android is missing native Promise reject with a
userInfo
WritableMap
support and alsonativeStack
support (which addressesTODO(8850038)
). This PR adds Android support for both of these.React Native on iOS (here) and Windows (here) already support this so this is a relatively minor addition to bring Android in line with the other platforms. (JS support is also here)
Existing methods remain unchanged other than general cleanup of variable names (
e -> throwable
) and adding code comments/docs.Additionally, the
ShareTestModule
implementation of Promise (SimplePromise) was updated to reflect these changes - other line changes in this file are from formatting in Android Studio - if this is an issue let me know.Reason for changes
Test Plan:
2.1.
npm run test
- Jest tests2.2.
./scripts/run-android-local-integration-tests.sh
2.3.
./scripts/run-android-local-unit-tests.sh
2.4.
./scripts/test-manual-e2e.sh
- built Android and ran the app, clicked through several samples/examples including theShare
one with no issues.invertase/react-native-firebase
tests app (powered by Detox & Jet) to build from RN Android source with the diff from this PR applied. All our e2e test suites ran with no issues - several hundred methods using Androids native Promise Implementation tested with no issues.4.1. /com/testing/RNPromiseTest.java - native module exposing all variations of
PromiseImpl
's methods4.2. /tests/e2e/promise.e2e.js JS test suite directly calling these methods from 4.1 and validating codes, messages, default codes & messages, types, instanceof checks and
nativeStack
frames.Feedback
Would be good to get some feedback on the following:
void reject(String message);
- can this deprecated method be removed? It's several versions old and I couldn't find any usages of it anymore.nativeStack*
platform format - the support I added fornativeStackAndroid
provides an array of Stack Frames in the same format as already utilised in RN JavaScript code here - this makes it easier to convert to a JS like stack trace if needed or for Crash/Error reporting frameworks to utilise. However, the pre-existing iOS support atnativeStackIOS
provides an unparsed array of call stack symbols which personally I'm not too keen on. What may be good is if both platforms return the same Stack Frame format as implemented on Android in this PR. Once both platforms are in the same format they can then just usenativeStack
rather than the current post-fixed key names. Feedback would be appreciated :) I could unify these in a subsequent PR based on the feedback - right now not a major issue as the keys are post-fixed by platform.Release Notes:
WritableMap
arg for extra properties (userInfo
). See the inteface defined inPromise.java
for available methods. Accessible in JavaScript asError.userInfo
. This is to match iOS's existingError.userInfo
support.nativeStackAndroid
property to promises rejected with anException/Throwable
- making native error stacks available inside Javascript:Error.nativeStackAndroid
. This is to match iOS's existingError.nativeStackIOS
support.