Skip to content

Commit 06dc51f

Browse files
esprehngrabbou
authored andcommitted
Don't crash on second resolve or reject in PromiseImpl. (facebook#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 facebook#20262 Pull Request resolved: facebook#20303 Differential Revision: D13396975 Pulled By: cpojer fbshipit-source-id: 81f14f73654fa7c44e043f574a39fda481ace44b
1 parent 319fa03 commit 06dc51f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ReactAndroid/src/main/java/com/facebook/react/bridge/PromiseImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public PromiseImpl(@Nullable Callback resolve, @Nullable Callback reject) {
2828
public void resolve(Object value) {
2929
if (mResolve != null) {
3030
mResolve.invoke(value);
31+
mResolve = null;
32+
mReject = null;
3133
}
3234
}
3335

@@ -67,5 +69,7 @@ public void reject(String code, String message, @Nullable Throwable e) {
6769
// TODO(8850038): add the stack trace info in, need to figure out way to serialize that
6870
mReject.invoke(errorInfo);
6971
}
72+
mResolve = null;
73+
mReject = null;
7074
}
7175
}

0 commit comments

Comments
 (0)