Skip to content

Commit

Permalink
catch unhandled rejection with installation-handling (#3795)
Browse files Browse the repository at this point in the history
  • Loading branch information
kahoona77 authored and flovilmart committed May 9, 2017
1 parent 8d67776 commit 64e6f40
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/RestWrite.js
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,15 @@ RestWrite.prototype.handleInstallation = function() {
if (this.data.appIdentifier) {
delQuery['appIdentifier'] = this.data.appIdentifier;
}
this.config.database.destroy('_Installation', delQuery);
this.config.database.destroy('_Installation', delQuery)
.catch(err => {
if (err.code == Parse.Error.OBJECT_NOT_FOUND) {
// no deletions were made. Can be ignored.
return;
}
// rethrow the error
throw err;
});
return;
}
} else {
Expand All @@ -806,6 +814,14 @@ RestWrite.prototype.handleInstallation = function() {
return this.config.database.destroy('_Installation', delQuery)
.then(() => {
return deviceTokenMatches[0]['objectId'];
})
.catch(err => {
if (err.code == Parse.Error.OBJECT_NOT_FOUND) {
// no deletions were made. Can be ignored
return;
}
// rethrow the error
throw err;
});
} else {
if (this.data.deviceToken &&
Expand Down Expand Up @@ -835,7 +851,15 @@ RestWrite.prototype.handleInstallation = function() {
if (this.data.appIdentifier) {
delQuery['appIdentifier'] = this.data.appIdentifier;
}
this.config.database.destroy('_Installation', delQuery);
this.config.database.destroy('_Installation', delQuery)
.catch(err => {
if (err.code == Parse.Error.OBJECT_NOT_FOUND) {
// no deletions were made. Can be ignored.
return;
}
// rethrow the error
throw err;
});
}
// In non-merge scenarios, just return the installation match id
return idMatch.objectId;
Expand Down

0 comments on commit 64e6f40

Please sign in to comment.