-
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
Bridge promises don't handle multiple resolve or reject calls properly #20262
Comments
This happens in the most recent version too. The code is the same. |
@esprehn can you update your post accordingly? 0.54.4 is not the latest as of this writing, and we'd like to know the exact version you tested in. |
@hramos It happens in the most recent version as well. The code is here: The bridge makes the callbacks here: react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaMethodWrapper.java Line 126 in 26684cf
which contains the throw statement: react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CallbackImpl.java Line 28 in 26684cf
None of the related files have been touched since the relicensing in Feb. For Android this could be fixed by setting mResolve and mReject to null, for iOS I'd need to study the bridge code more, it doesn't have the same kind of Promise abstraction, instead it seems to just pass two blocks into your method. |
This does actually crash on iOS in a debug build, I misread the code: react-native/React/Base/RCTModuleMethod.mm Line 119 in 30b9d81
|
I am closing this issue because it does not appear to have been verified on the latest release, and there has been no followup in a while. If you found this thread after encountering the same issue in the latest release, please feel free to create a new issue with up-to-date information by clicking here. |
This bug still exists. @hramos The bot probably shouldn't close issues with pending PRs? |
@esprehn the bot won't close issues with a pending PR, but this issue was not labeled as such at the time of closing. Can you update your original post and make sure it mentions the actual version you tested in? Otherwise the bot might close it again for referring to an older version (0.56 is latest at this time). |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions. |
This issue still exists. Bridge promises don't follow the spec. |
Summary: Promise semantics per JS should allow calling resolve or reject repeatedly without crashing. Only the first one should do anything, but others should be allowed. This change fixes the Java bridge for Android. A separate change is needed for iOS. Issue #20262 Pull Request resolved: #20303 Differential Revision: D13396975 Pulled By: cpojer fbshipit-source-id: 81f14f73654fa7c44e043f574a39fda481ace44b
Summary: Promise semantics per JS should allow calling resolve or reject repeatedly without crashing. Only the first one should do anything, but others should be allowed. This change fixes the Java bridge for Android. A separate change is needed for iOS. Issue #20262 Pull Request resolved: #20303 Differential Revision: D13396975 Pulled By: cpojer fbshipit-source-id: 81f14f73654fa7c44e043f574a39fda481ace44b
This issue if fixed in 0.59. Thank you |
Summary: Promise semantics per JS should allow calling resolve or reject repeatedly without crashing. Only the first one should do anything, but others should be allowed. This change fixes the Java bridge for Android. A separate change is needed for iOS. Issue facebook#20262 Pull Request resolved: facebook#20303 Differential Revision: D13396975 Pulled By: cpojer fbshipit-source-id: 81f14f73654fa7c44e043f574a39fda481ace44b
Environment
Environment:
OS: macOS High Sierra 10.13.5
Node: 8.9.4
Yarn: 1.5.1
npm: 5.6.0
Watchman: 4.7.0
Xcode: Xcode 9.4.1 Build version 9F2000
Android Studio: 3.1 AI-173.4720617
Packages: (wanted => installed)
react: 16.2.0 => 16.2.0
react-native: 0.54.4 => 0.54.4
Description
PromiseImpl and RCTModuleMethod don't handle promise resolution properly. Resolving a promise a second time is supposed to have no effect per ES semantics, similarly rejecting it a second time, or if it's rejected already, should have no effect.
PromiseImpl.resolve a second time will throw an error:
For iOS this doesn't crash in ObjC, instead it sends another message over the bridge, but the callbacks are gone, so it incorrectly warns in a dev build (
Callback with id ${cbID}: ${module}.${method}() not found
) and is correctly a no-op in a release build (though it is inefficient to send the bridge response).Reproducible Demo
Create a
@RectMethod
and do resolve() in the Java twice, or do do resolve twice in an ObjC iOS method.The text was updated successfully, but these errors were encountered: