diff --git a/src/public/javascripts/services/ws.js b/src/public/javascripts/services/ws.js index 315c31a33..c258fd2db 100644 --- a/src/public/javascripts/services/ws.js +++ b/src/public/javascripts/services/ws.js @@ -106,7 +106,7 @@ function checkSyncIdListeners() { .filter(l => l.desiredSyncId > lastSyncId); syncIdReachedListeners.filter(l => Date.now() > l.start - 60000) - .forEach(l => console.log(`Waiting for syncId ${l.desiredSyncId} while current is ${lastSyncId} for ${Date.now() - l.start}`)); + .forEach(l => console.log(`Waiting for syncId ${l.desiredSyncId} while current is ${lastSyncId} for ${Math.floor((Date.now() - l.start) / 1000)}s`)); } async function consumeSyncData() { diff --git a/src/services/ws.js b/src/services/ws.js index de7c92ae6..7661afca5 100644 --- a/src/services/ws.js +++ b/src/services/ws.js @@ -5,7 +5,6 @@ const sql = require('./sql'); const syncMutexService = require('./sync_mutex'); let webSocketServer; -let lastSyncId = 0; function init(httpServer, sessionParser) { webSocketServer = new WebSocket.Server({ @@ -29,13 +28,11 @@ function init(httpServer, sessionParser) { ws.on('message', messageJson => { const message = JSON.parse(messageJson); - lastSyncId = Math.max(lastSyncId, message.lastSyncId); - if (message.type === 'log-error') { log.error('JS Error: ' + message.error); } else if (message.type === 'ping') { - syncMutexService.doExclusively(async () => await sendPing(ws, lastSyncId)); + syncMutexService.doExclusively(async () => await sendPing(ws, message.lastSyncId)); } else { log.error('Unrecognized message: ');