mirror of
https://github.com/zadam/trilium.git
synced 2024-09-21 16:16:04 +08:00
tweaks in sync timeout handling
This commit is contained in:
parent
5f4a84d967
commit
8a57960c6e
|
@ -51,7 +51,7 @@ async function initNotSyncedOptions(initialized, startNotePath = 'root', opts =
|
||||||
await optionService.createOption('theme', opts.theme || 'white', false);
|
await optionService.createOption('theme', opts.theme || 'white', false);
|
||||||
|
|
||||||
await optionService.createOption('syncServerHost', opts.syncServerHost || '', false);
|
await optionService.createOption('syncServerHost', opts.syncServerHost || '', false);
|
||||||
await optionService.createOption('syncServerTimeout', '5000', false);
|
await optionService.createOption('syncServerTimeout', '60000', false);
|
||||||
await optionService.createOption('syncProxy', opts.syncProxy || '', false);
|
await optionService.createOption('syncProxy', opts.syncProxy || '', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,9 @@ async function pullSync(syncContext) {
|
||||||
const startDate = Date.now();
|
const startDate = Date.now();
|
||||||
|
|
||||||
const resp = await syncRequest(syncContext, 'GET', changesUri);
|
const resp = await syncRequest(syncContext, 'GET', changesUri);
|
||||||
|
|
||||||
|
const pulledDate = Date.now();
|
||||||
|
|
||||||
stats.outstandingPulls = resp.maxSyncId - lastSyncedPull;
|
stats.outstandingPulls = resp.maxSyncId - lastSyncedPull;
|
||||||
|
|
||||||
if (stats.outstandingPulls < 0) {
|
if (stats.outstandingPulls < 0) {
|
||||||
|
@ -162,7 +165,7 @@ async function pullSync(syncContext) {
|
||||||
await setLastSyncedPull(rows[rows.length - 1].sync.id);
|
await setLastSyncedPull(rows[rows.length - 1].sync.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
log.info(`Pulled and updated ${rows.length} changes from ${changesUri} in ${Date.now() - startDate}ms`);
|
log.info(`Pulled ${rows.length} changes in ${pulledDate - startDate}ms from ${changesUri} and applied them in ${Date.now() - pulledDate}ms`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appliedPulls > 0) {
|
if (appliedPulls > 0) {
|
||||||
|
|
|
@ -218,6 +218,9 @@ function formatDownloadTitle(filename, type, mime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function timeLimit(promise, limitMs) {
|
function timeLimit(promise, limitMs) {
|
||||||
|
// better stack trace if created outside of promise
|
||||||
|
const error = new Error('Process exceeded time limit ' + limitMs);
|
||||||
|
|
||||||
return new Promise((res, rej) => {
|
return new Promise((res, rej) => {
|
||||||
let resolved = false;
|
let resolved = false;
|
||||||
|
|
||||||
|
@ -229,7 +232,7 @@ function timeLimit(promise, limitMs) {
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!resolved) {
|
if (!resolved) {
|
||||||
rej(new Error('Process exceeded time limit ' + limitMs));
|
rej(error);
|
||||||
}
|
}
|
||||||
}, limitMs);
|
}, limitMs);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue