From bc97cd3c5daa096522c69362bf89daf09614c5b2 Mon Sep 17 00:00:00 2001 From: Kurounin Date: Fri, 9 Sep 2016 10:25:39 +0300 Subject: [PATCH 1/3] Fixed rescheduling jobs when mongodb timed out during execution of job. --- synced-cron-server.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/synced-cron-server.js b/synced-cron-server.js index 2378967..cf60949 100644 --- a/synced-cron-server.js +++ b/synced-cron-server.js @@ -225,11 +225,11 @@ SyncedCron._entryWrapper = function(entry) { } }); } catch(e) { - log.info('Exception "' + entry.name +'" ' + e.stack); + log.info('Exception "' + entry.name +'" ' + ((e && e.stack) ? e.stack : e)); self._collection.update({_id: jobHistory._id}, { $set: { finishedAt: new Date(), - error: e.stack + error: (e && e.stack) ? e.stack : e } }); } @@ -263,7 +263,12 @@ SyncedCron._laterSetInterval = function(fn, sched) { */ function scheduleTimeout(intendedAt) { if(!done) { - fn(intendedAt); + try { + fn(intendedAt); + } catch(e) { + log.info('Exception running scheduled job ' + ((e && e.stack) ? e.stack : e)); + } + t = SyncedCron._laterSetTimeout(scheduleTimeout, sched); } } From a6259abaabd052abb9a30ce732683a469a6f586c Mon Sep 17 00:00:00 2001 From: Michal Wanat Date: Tue, 13 Dec 2016 22:32:54 +0100 Subject: [PATCH 2/3] fix for issue #69 --- 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 2378967..7f2b94b 100644 --- a/synced-cron-server.js +++ b/synced-cron-server.js @@ -209,7 +209,7 @@ SyncedCron._entryWrapper = function(entry) { return; } - throw e; + console.error(e); }; // run and record the job From 6e0772a4c7058f3ff77ab524bc6da1d899848013 Mon Sep 17 00:00:00 2001 From: Michal Wanat Date: Wed, 14 Dec 2016 15:19:11 +0100 Subject: [PATCH 3/3] fix --- synced-cron-server.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/synced-cron-server.js b/synced-cron-server.js index c02eed9..ded4241 100644 --- a/synced-cron-server.js +++ b/synced-cron-server.js @@ -209,7 +209,7 @@ SyncedCron._entryWrapper = function(entry) { return; } - console.error(e); + throw e; }; // run and record the job @@ -225,11 +225,11 @@ SyncedCron._entryWrapper = function(entry) { } }); } catch(e) { - log.info('Exception "' + entry.name +'" ' + ((e && e.stack) ? e.stack : e)); + log.info('Exception "' + entry.name +'" ' + (e && e.stack || e)); self._collection.update({_id: jobHistory._id}, { $set: { finishedAt: new Date(), - error: (e && e.stack) ? e.stack : e + error: e && e.stack || e } }); } @@ -266,7 +266,7 @@ SyncedCron._laterSetInterval = function(fn, sched) { try { fn(intendedAt); } catch(e) { - log.info('Exception running scheduled job ' + ((e && e.stack) ? e.stack : e)); + log.info('Exception running scheduled job ' + (e && e.stack || e)); } t = SyncedCron._laterSetTimeout(scheduleTimeout, sched);