Merge pull request #603 from gyfelton/transaction-promise-resolve

Make sure the promise is resolved/rejected for transaction
This commit is contained in:
Elliot Hesp 2017-11-20 09:27:14 +00:00 committed by GitHub
commit 78a2b0a81a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);