From 6e11a2c8a77884806b341cf9e611581bea8519a0 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Tue, 5 Apr 2016 15:43:29 +0800 Subject: [PATCH] fix: use better diff time to check sync status closes #858 --- sync/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sync/index.js b/sync/index.js index a88996869..04474a12a 100644 --- a/sync/index.js +++ b/sync/index.js @@ -195,9 +195,11 @@ function* checkSyncStatus() { } var diff = Date.now() - lastSyncTime; var oneDay = 3600000 * 24; - if (diff > oneDay) { - var err = new Error('Last sync time is expired in ' + diff + ' ms, lastSyncTime: ' + new Date(lastSyncTime)); - err.name = 'SyncExpriedError'; + var maxTime = Math.max(oneDay, syncInterval * 2); + if (diff > maxTime) { + var err = new Error('Last sync time is expired in ' + diff + ' ms, lastSyncTime: ' + + new Date(lastSyncTime) + ', maxTime: ' + maxTime + ' ms'); + err.name = 'SyncExpiredError'; sendMailToAdmin(err, null, new Date()); } }