mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	add time limit to frontend update
This commit is contained in:
		@@ -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 {
 | 
			
		||||
    reloadApp,
 | 
			
		||||
    parseDate,
 | 
			
		||||
@@ -355,5 +373,6 @@ export default {
 | 
			
		||||
    normalizeShortcut,
 | 
			
		||||
    copySelectionToClipboard,
 | 
			
		||||
    isCKEditorInitialized,
 | 
			
		||||
    dynamicRequire
 | 
			
		||||
    dynamicRequire,
 | 
			
		||||
    timeLimit
 | 
			
		||||
};
 | 
			
		||||
@@ -157,7 +157,7 @@ async function consumeSyncData() {
 | 
			
		||||
        const nonProcessedSyncRows = allSyncRows.filter(sync => !processedSyncIds.has(sync.id));
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            await processSyncRows(nonProcessedSyncRows);
 | 
			
		||||
            await utils.timeLimit(async () => await processSyncRows(nonProcessedSyncRows), 5000);
 | 
			
		||||
        }
 | 
			
		||||
        catch (e) {
 | 
			
		||||
            logError(`Encountered error ${e.message}: ${e.stack}, reloading frontend.`);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user