Don't crash on second resolve or reject in PromiseImpl. (#20303)
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: https://github.com/facebook/react-native/pull/20303 Differential Revision: D13396975 Pulled By: cpojer fbshipit-source-id: 81f14f73654fa7c44e043f574a39fda481ace44b
This commit is contained in:
parent
3592122af3
commit
167d7861cb
|
@ -28,6 +28,8 @@ public class PromiseImpl implements Promise {
|
|||
public void resolve(Object value) {
|
||||
if (mResolve != null) {
|
||||
mResolve.invoke(value);
|
||||
mResolve = null;
|
||||
mReject = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,5 +69,7 @@ public class PromiseImpl implements Promise {
|
|||
// TODO(8850038): add the stack trace info in, need to figure out way to serialize that
|
||||
mReject.invoke(errorInfo);
|
||||
}
|
||||
mResolve = null;
|
||||
mReject = null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue