diff --git a/common/models/change.js b/common/models/change.js index f6adc5cf..53368813 100644 --- a/common/models/change.js +++ b/common/models/change.js @@ -344,6 +344,9 @@ module.exports = function(Change) { */ Change.diff = function(modelName, since, remoteChanges, callback) { + if (!Array.isArray(remoteChanges) || remoteChanges.length === 0) { + return callback(null, {deltas: [], conflicts: []}); + } var remoteChangeIndex = {}; var modelIds = []; remoteChanges.forEach(function(ch) { diff --git a/lib/persisted-model.js b/lib/persisted-model.js index c6c60374..a4b4a5b2 100644 --- a/lib/persisted-model.js +++ b/lib/persisted-model.js @@ -728,6 +728,7 @@ PersistedModel.changes = function(since, filter, callback) { modelName: this.modelName }, function(err, changes) { if (err) return callback(err); + if (!Array.isArray(changes) || changes.length === 0) return callback(null, []); var ids = changes.map(function(change) { return change.getModelId(); });