Make sure the promise is resolved/rejected for transaction

Right now the following code will be broken:
```
async function() {
  await ref.transaction(
              function(foo) {
                 // deal with foo
              },
              function(error, committed, ss) {
                 // additional work on complete callback
              },
              true
          );
  // NOTE: Code from here will never execute because promise above never gets resolved
}
```
v2 is not returning at the point of calling onComplete, v3 code does
This commit is contained in:
Elton Gao 2017-11-09 10:34:52 -05:00 committed by Elton Gao
parent 89ce31689e
commit 0c550f3586
1 changed files with 5 additions and 2 deletions

View File

@ -195,8 +195,11 @@ export default class Reference extends ReferenceBase {
return new Promise((resolve, reject) => {
const onCompleteWrapper = (error, committed, snapshotData) => {
if (isFunction(onComplete)) {
if (error) return onComplete(error, committed, null);
return onComplete(null, committed, new Snapshot(this, snapshotData));
if (error) {
onComplete(error, committed, null);
} else {
onComplete(null, committed, new Snapshot(this, snapshotData));
}
}
if (error) return reject(error);