Skip to content

Commit

Permalink
Fix error handling for Meteor 1.7.
Browse files Browse the repository at this point in the history
Meteor 1.7 uses v3 of the Mongo driver, which changes
the errors thrown by bulk operations.  Meteor uses .insert()
rather than .insertOne(), so is affected.  As a result, with
Meteor 1.7, the error's name is BulkWriteError, not MongoError.

This commit makes the check compatible with both v2 and v3 of the
Mongo driver, by checking just the error code, not the name.
  • Loading branch information
Or Neeman authored and TheGame2500 committed Aug 6, 2018
1 parent a82a356 commit 687e9ea
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion synced-cron-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ SyncedCron._entryWrapper = function(entry) {
} catch(e) {
// http://www.mongodb.org/about/contributors/error-codes/
// 11000 == duplicate key error
if (e.name === 'MongoError' && e.code === 11000) {
if (e.code === 11000) {
log.info('Not running "' + entry.name + '" again.');
return;
}
Expand Down

0 comments on commit 687e9ea

Please sign in to comment.