Skip to content

Commit 64e6f40

Browse files
kahoona77flovilmart
kahoona77
authored andcommitted
catch unhandled rejection with installation-handling (#3795)
1 parent 8d67776 commit 64e6f40

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/RestWrite.js

+26-2
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,15 @@ RestWrite.prototype.handleInstallation = function() {
793793
if (this.data.appIdentifier) {
794794
delQuery['appIdentifier'] = this.data.appIdentifier;
795795
}
796-
this.config.database.destroy('_Installation', delQuery);
796+
this.config.database.destroy('_Installation', delQuery)
797+
.catch(err => {
798+
if (err.code == Parse.Error.OBJECT_NOT_FOUND) {
799+
// no deletions were made. Can be ignored.
800+
return;
801+
}
802+
// rethrow the error
803+
throw err;
804+
});
797805
return;
798806
}
799807
} else {
@@ -806,6 +814,14 @@ RestWrite.prototype.handleInstallation = function() {
806814
return this.config.database.destroy('_Installation', delQuery)
807815
.then(() => {
808816
return deviceTokenMatches[0]['objectId'];
817+
})
818+
.catch(err => {
819+
if (err.code == Parse.Error.OBJECT_NOT_FOUND) {
820+
// no deletions were made. Can be ignored
821+
return;
822+
}
823+
// rethrow the error
824+
throw err;
809825
});
810826
} else {
811827
if (this.data.deviceToken &&
@@ -835,7 +851,15 @@ RestWrite.prototype.handleInstallation = function() {
835851
if (this.data.appIdentifier) {
836852
delQuery['appIdentifier'] = this.data.appIdentifier;
837853
}
838-
this.config.database.destroy('_Installation', delQuery);
854+
this.config.database.destroy('_Installation', delQuery)
855+
.catch(err => {
856+
if (err.code == Parse.Error.OBJECT_NOT_FOUND) {
857+
// no deletions were made. Can be ignored.
858+
return;
859+
}
860+
// rethrow the error
861+
throw err;
862+
});
839863
}
840864
// In non-merge scenarios, just return the installation match id
841865
return idMatch.objectId;

0 commit comments

Comments
 (0)