non-intrusive logging of sync errors

This commit is contained in:
zadam 2020-07-01 21:33:52 +02:00
parent bf073690e0
commit f0b608ddec
5 changed files with 13 additions and 19 deletions

View File

@ -99,15 +99,12 @@ if (!fs.existsSync(dataDir.BACKUP_DIR)) {
fs.mkdirSync(dataDir.BACKUP_DIR, 0o700);
}
// hack
setTimeout(() => {
sqlInit.dbReady.then(() => {
sqlInit.dbReady.then(() => {
setInterval(cls.wrap(regularBackup), 4 * 60 * 60 * 1000);
// kickoff first backup soon after start up
setTimeout(cls.wrap(regularBackup), 5 * 60 * 1000);
});
}, 5000);
});
module.exports = {
backupNow,

View File

@ -2,6 +2,7 @@ const utils = require('./utils');
const dateUtils = require('./date_utils');
const log = require('./log');
const sql = require('./sql');
const sqlInit = require('./sql_init');
const cls = require('./cls');
function saveSourceId(sourceId) {
@ -46,12 +47,7 @@ function isLocalSourceId(srcId) {
const currentSourceId = createSourceId();
// very ugly
setTimeout(() => {
const sqlInit = require('./sql_init');
sqlInit.dbReady.then(cls.wrap(() => saveSourceId(currentSourceId)));
}, 5000);
sqlInit.dbReady.then(cls.wrap(() => saveSourceId(currentSourceId)));
function getCurrentSourceId() {
return currentSourceId;

View File

@ -87,7 +87,7 @@ async function login() {
await setupService.sendSeedToSyncServer();
}
return doLogin();
return await doLogin();
}
async function doLogin() {
@ -257,7 +257,7 @@ async function checkContentHash(syncContext) {
return failedChecks.length > 0;
}
function syncRequest(syncContext, method, requestPath, body) {
async function syncRequest(syncContext, method, requestPath, body) {
const timeout = syncOptions.getSyncTimeout();
const opts = {
@ -269,7 +269,7 @@ function syncRequest(syncContext, method, requestPath, body) {
proxy: proxyToggle ? syncOptions.getSyncProxy() : null
};
return utils.timeLimit(request.exec(opts), timeout);
return await utils.timeLimit(request.exec(opts), timeout);
}
const primaryKeys = {

View File

@ -10,7 +10,7 @@ async function doExclusively(func) {
const releaseMutex = await instance.acquire();
try {
return func();
return await func();
}
finally {
releaseMutex();

View File

@ -244,7 +244,8 @@ function timeLimit(promise, limitMs) {
resolved = true;
res(result);
});
})
.catch(error => rej(error));
setTimeout(() => {
if (!resolved) {