mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
add time limit to frontend update
This commit is contained in:
parent
910bda860c
commit
d09b021487
@ -316,6 +316,24 @@ function dynamicRequire(moduleName) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function timeLimit(cb, limitMs) {
|
||||||
|
return new Promise((res, rej) => {
|
||||||
|
let resolved = false;
|
||||||
|
|
||||||
|
cb().then(() => {
|
||||||
|
resolved = true;
|
||||||
|
|
||||||
|
res();
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!resolved) {
|
||||||
|
rej('Process exceeded time limit ' + limitMs);
|
||||||
|
}
|
||||||
|
}, limitMs);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
reloadApp,
|
reloadApp,
|
||||||
parseDate,
|
parseDate,
|
||||||
@ -355,5 +373,6 @@ export default {
|
|||||||
normalizeShortcut,
|
normalizeShortcut,
|
||||||
copySelectionToClipboard,
|
copySelectionToClipboard,
|
||||||
isCKEditorInitialized,
|
isCKEditorInitialized,
|
||||||
dynamicRequire
|
dynamicRequire,
|
||||||
|
timeLimit
|
||||||
};
|
};
|
@ -157,7 +157,7 @@ async function consumeSyncData() {
|
|||||||
const nonProcessedSyncRows = allSyncRows.filter(sync => !processedSyncIds.has(sync.id));
|
const nonProcessedSyncRows = allSyncRows.filter(sync => !processedSyncIds.has(sync.id));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await processSyncRows(nonProcessedSyncRows);
|
await utils.timeLimit(async () => await processSyncRows(nonProcessedSyncRows), 5000);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
logError(`Encountered error ${e.message}: ${e.stack}, reloading frontend.`);
|
logError(`Encountered error ${e.message}: ${e.stack}, reloading frontend.`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user