From 687e9ea308a287fe6347f94e0fb3eac5e2e21c12 Mon Sep 17 00:00:00 2001 From: Or Neeman Date: Tue, 10 Jul 2018 09:26:07 -0600 Subject: [PATCH] Fix error handling for Meteor 1.7. 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. --- synced-cron-server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synced-cron-server.js b/synced-cron-server.js index 37b926e..7b80f09 100644 --- a/synced-cron-server.js +++ b/synced-cron-server.js @@ -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; }