From 108afe8896d56f721cb4da3cf80e7b5f822112f6 Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 14 May 2020 13:08:06 +0200 Subject: [PATCH 1/3] fix incorrect processing of sync rows, closes #1019 --- src/public/app/services/load_results.js | 8 +-- src/public/app/services/ws.js | 92 ++++++++++++++----------- 2 files changed, 54 insertions(+), 46 deletions(-) diff --git a/src/public/app/services/load_results.js b/src/public/app/services/load_results.js index ddd174a24..89965e8f3 100644 --- a/src/public/app/services/load_results.js +++ b/src/public/app/services/load_results.js @@ -4,7 +4,7 @@ export default class LoadResults { this.noteIdToSourceId = {}; this.sourceIdToNoteIds = {}; - + this.branches = []; this.attributes = []; @@ -103,10 +103,10 @@ export default class LoadResults { /** * @return {boolean} true if there are changes which could affect the attributes (including inherited ones) + * notably changes in note itself should not have any effect on attributes */ hasAttributeRelatedChanges() { - return Object.keys(this.noteIdToSourceId).length === 0 - && this.branches.length === 0 + return this.branches.length === 0 && this.attributes.length === 0; } @@ -119,4 +119,4 @@ export default class LoadResults { && this.contentNoteIdToSourceId.length === 0 && this.options.length === 0; } -} \ No newline at end of file +} diff --git a/src/public/app/services/ws.js b/src/public/app/services/ws.js index 6c4e6e160..e20ecc5fb 100644 --- a/src/public/app/services/ws.js +++ b/src/public/app/services/ws.js @@ -39,7 +39,18 @@ let consumeQueuePromise = null; // most sync events are sent twice - once immediatelly after finishing the transaction and once during the scheduled ping // but we want to process only once -const receivedSyncIds = new Set(); +const processedSyncIds = new Set(); + +function logRows(syncRows) { + const filteredRows = syncRows.filter(row => + !processedSyncIds.has(row.id) + && row.entityName !== 'recent_notes' + && (row.entityName !== 'options' || row.entityId !== 'openTabs')); + + if (filteredRows.length > 0) { + console.debug(utils.now(), "Sync data: ", filteredRows); + } +} async function handleMessage(event) { const message = JSON.parse(event.data); @@ -55,20 +66,9 @@ async function handleMessage(event) { $outstandingSyncsCount.html(message.outstandingSyncs); if (syncRows.length > 0) { - const filteredRows = syncRows.filter(row => - !receivedSyncIds.has(row.id) - && row.entityName !== 'recent_notes' - && (row.entityName !== 'options' || row.entityId !== 'openTabs')); + logRows(syncRows); - if (filteredRows.length > 0) { - console.debug(utils.now(), "Sync data: ", filteredRows); - } - - for (const row of filteredRows) { - receivedSyncIds.add(row.id); - } - - syncDataQueue.push(...filteredRows); + syncDataQueue.push(...syncRows); // we set lastAcceptedSyncId even before sync processing and send ping so that backend can start sending more updates lastAcceptedSyncId = Math.max(lastAcceptedSyncId, syncRows[syncRows.length - 1].id); @@ -142,13 +142,21 @@ async function runSafely(syncHandler, syncData) { } } +/** + * TODO: we should rethink the fact that each sync row is sent twice (once at the end of transaction, once periodically) + * and we keep both lastProcessedSyncId and processedSyncIds + * it even seems incorrect that when transaction sync rows are received, we incorrectly increase lastProcessedSyncId + * and then some syncs might lost (or are *all* sync rows sent from transactions?) + */ async function consumeSyncData() { if (syncDataQueue.length > 0) { - const allSyncData = syncDataQueue; + const allSyncRows = syncDataQueue; syncDataQueue = []; + const nonProcessedSyncRows = allSyncRows.filter(sync => !processedSyncIds.has(sync.id)); + try { - await processSyncRows(allSyncData); + await processSyncRows(nonProcessedSyncRows); } catch (e) { logError(`Encountered error ${e.message}: ${e.stack}, reloading frontend.`); @@ -157,7 +165,7 @@ async function consumeSyncData() { utils.reloadApp(); } - lastProcessedSyncId = Math.max(lastProcessedSyncId, allSyncData[allSyncData.length - 1].id); + lastProcessedSyncId = Math.max(lastProcessedSyncId, allSyncRows[allSyncRows.length - 1].id); } checkSyncIdListeners(); @@ -221,18 +229,18 @@ subscribeToMessages(message => { async function processSyncRows(syncRows) { const missingNoteIds = []; - syncRows.forEach(({entityName, entity}) => { - if (entityName === 'branches' && !(entity.parentNoteId in treeCache.notes)) { + for (const {id, entityName, entity} of syncRows) { + if (entityName === 'branches' && !(entity.parentNoteId in treeCache.notes)) { missingNoteIds.push(entity.parentNoteId); - } - else if (entityName === 'attributes' - && entity.type === 'relation' - && entity.name === 'template' - && !(entity.noteId in treeCache.notes)) { + } + else if (entityName === 'attributes' + && entity.type === 'relation' + && entity.name === 'template' + && !(entity.noteId in treeCache.notes)) { - missingNoteIds.push(entity.value); - } - }); + missingNoteIds.push(entity.value); + } + } if (missingNoteIds.length > 0) { await treeCache.reloadNotes(missingNoteIds); @@ -240,16 +248,16 @@ async function processSyncRows(syncRows) { const loadResults = new LoadResults(treeCache); - syncRows.filter(sync => sync.entityName === 'notes').forEach(sync => { + for (const sync of syncRows.filter(sync => sync.entityName === 'notes')) { const note = treeCache.notes[sync.entityId]; if (note) { note.update(sync.entity); loadResults.addNote(sync.entityId, sync.sourceId); } - }); + } - syncRows.filter(sync => sync.entityName === 'branches').forEach(sync => { + for (const sync of syncRows.filter(sync => sync.entityName === 'branches')) { let branch = treeCache.branches[sync.entityId]; const childNote = treeCache.notes[sync.entity.noteId]; const parentNote = treeCache.notes[sync.entity.parentNoteId]; @@ -295,9 +303,9 @@ async function processSyncRows(syncRows) { } } } - }); + } - syncRows.filter(sync => sync.entityName === 'note_reordering').forEach(sync => { + for (const sync of syncRows.filter(sync => sync.entityName === 'note_reordering')) { for (const branchId in sync.positions) { const branch = treeCache.branches[branchId]; @@ -307,10 +315,10 @@ async function processSyncRows(syncRows) { } loadResults.addNoteReordering(sync.entityId, sync.sourceId); - }); + } // missing reloading the relation target note - syncRows.filter(sync => sync.entityName === 'attributes').forEach(sync => { + for (const sync of syncRows.filter(sync => sync.entityName === 'attributes')) { let attribute = treeCache.attributes[sync.entityId]; const sourceNote = treeCache.notes[sync.entity.noteId]; const targetNote = sync.entity.type === 'relation' && treeCache.notes[sync.entity.value]; @@ -346,27 +354,27 @@ async function processSyncRows(syncRows) { } } } - }); + } - syncRows.filter(sync => sync.entityName === 'note_contents').forEach(sync => { + for (const sync of syncRows.filter(sync => sync.entityName === 'note_contents')) { delete treeCache.noteComplementPromises[sync.entityId]; loadResults.addNoteContent(sync.entityId, sync.sourceId); - }); + } - syncRows.filter(sync => sync.entityName === 'note_revisions').forEach(sync => { + for (const sync of syncRows.filter(sync => sync.entityName === 'note_revisions')) { loadResults.addNoteRevision(sync.entityId, sync.noteId, sync.sourceId); - }); + } - syncRows.filter(sync => sync.entityName === 'options').forEach(sync => { + for (const sync of syncRows.filter(sync => sync.entityName === 'options')) { if (sync.entity.name === 'openTabs') { - return; // only noise + continue; // only noise } options.set(sync.entity.name, sync.entity.value); loadResults.addOption(sync.entity.name); - }); + } if (!loadResults.isEmpty()) { if (loadResults.hasAttributeRelatedChanges()) { From fa5d982a553ec428d521716c009da9382634c04f Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 17 May 2020 21:07:54 +0200 Subject: [PATCH 2/3] fix exporting root note, closes #1024 --- src/public/app/services/tree.js | 9 ++++++++- src/routes/api/export.js | 10 +++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/public/app/services/tree.js b/src/public/app/services/tree.js index 4910f4c36..40254a890 100644 --- a/src/public/app/services/tree.js +++ b/src/public/app/services/tree.js @@ -162,6 +162,13 @@ function getNoteIdFromNotePath(notePath) { } function getNoteIdAndParentIdFromNotePath(notePath) { + if (notePath === 'root') { + return { + noteId: 'root', + parentNoteId: 'none' + }; + } + let parentNoteId = 'root'; let noteId = ''; @@ -286,4 +293,4 @@ export default { getNotePathTitle, getHashValueFromAddress, parseNotePath -}; \ No newline at end of file +}; diff --git a/src/routes/api/export.js b/src/routes/api/export.js index 7464c793a..109b9bb7b 100644 --- a/src/routes/api/export.js +++ b/src/routes/api/export.js @@ -11,6 +11,14 @@ async function exportBranch(req, res) { const {branchId, type, format, version, taskId} = req.params; const branch = await repository.getBranch(branchId); + if (!branch) { + const message = `Cannot export branch ${branchId} since it does not exist.`; + log.error(message); + + res.status(500).send(message); + return; + } + const taskContext = new TaskContext(taskId, 'export'); try { @@ -39,4 +47,4 @@ async function exportBranch(req, res) { module.exports = { exportBranch -}; \ No newline at end of file +}; From 58f4f5d1e61a75ceb42b95ff17360fbf56d4f86b Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 19 May 2020 22:58:08 +0200 Subject: [PATCH 3/3] fix deadlock after "cut to note", closes #1030 --- .idea/dataSources.xml | 4 +- package-lock.json | 88 +++++++++++++-------------- package.json | 2 +- src/public/app/services/ws.js | 2 +- src/public/app/services/zoom.js | 8 ++- src/public/app/widgets/component.js | 6 +- src/public/app/widgets/note_detail.js | 5 +- 7 files changed, 61 insertions(+), 54 deletions(-) diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml index 70caa7f2a..2ee12209c 100644 --- a/.idea/dataSources.xml +++ b/.idea/dataSources.xml @@ -1,11 +1,11 @@ - + sqlite.xerial true org.sqlite.JDBC - jdbc:sqlite:$PROJECT_DIR$/../trilium-data/document.db + jdbc:sqlite:$USER_HOME$/trilium-data/document.db \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 837b0d31b..331341b20 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "trilium", - "version": "0.42.1", + "version": "0.42.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1263,7 +1263,7 @@ "dependencies": { "file-type": { "version": "3.9.0", - "resolved": "http://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=" } } @@ -1539,7 +1539,7 @@ }, "uuid": { "version": "2.0.3", - "resolved": "http://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", "integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=" } } @@ -1573,7 +1573,7 @@ "dependencies": { "semver": { "version": "4.3.6", - "resolved": "http://registry.npmjs.org/semver/-/semver-4.3.6.tgz", + "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz", "integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto=" } } @@ -1593,7 +1593,7 @@ }, "bl": { "version": "1.2.2", - "resolved": "http://registry.npmjs.org/bl/-/bl-1.2.2.tgz", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", "requires": { "readable-stream": "^2.3.5", @@ -1853,12 +1853,12 @@ "dependencies": { "file-type": { "version": "3.9.0", - "resolved": "http://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=" }, "uuid": { "version": "2.0.3", - "resolved": "http://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", "integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=" } } @@ -1973,7 +1973,7 @@ }, "readable-stream": { "version": "1.1.14", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "requires": { "core-util-is": "~1.0.0", @@ -2148,7 +2148,7 @@ }, "chalk": { "version": "1.1.3", - "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "requires": { "ansi-styles": "^2.2.1", @@ -2465,7 +2465,7 @@ }, "commander": { "version": "2.8.1", - "resolved": "http://registry.npmjs.org/commander/-/commander-2.8.1.tgz", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz", "integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=", "requires": { "graceful-readlink": ">= 1.0.0" @@ -3128,7 +3128,7 @@ }, "readable-stream": { "version": "1.1.14", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "requires": { "core-util-is": "~1.0.0", @@ -3345,9 +3345,9 @@ } }, "electron": { - "version": "9.0.0-beta.24", - "resolved": "https://registry.npmjs.org/electron/-/electron-9.0.0-beta.24.tgz", - "integrity": "sha512-25L3XMqm/1CCaV5CgU5ZkhKXw9830WeipJrTW0+VC5XTKp/3xHwhxyQ5G1kQnOTJd7IGwOamvw237D6e1YKnng==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/electron/-/electron-9.0.0.tgz", + "integrity": "sha512-JsaSQNPh+XDYkLj8APtVKTtvpb86KIG57W5OOss4TNrn8L3isC9LsCITwfnVmGIXHhvX6oY/weCtN5hAAytjVg==", "dev": true, "requires": { "@electron/get": "^1.0.1", @@ -4957,7 +4957,7 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" }, "getpass": { @@ -5221,7 +5221,7 @@ }, "got": { "version": "5.7.1", - "resolved": "http://registry.npmjs.org/got/-/got-5.7.1.tgz", + "resolved": "https://registry.npmjs.org/got/-/got-5.7.1.tgz", "integrity": "sha1-X4FjWmHkplifGAVp6k44FoClHzU=", "requires": { "create-error-class": "^3.0.1", @@ -5869,7 +5869,7 @@ }, "into-stream": { "version": "3.1.0", - "resolved": "http://registry.npmjs.org/into-stream/-/into-stream-3.1.0.tgz", + "resolved": "https://registry.npmjs.org/into-stream/-/into-stream-3.1.0.tgz", "integrity": "sha1-lvsKk2wSur1v8XUqF9BWFqvQlMY=", "requires": { "from2": "^2.1.1", @@ -6021,7 +6021,7 @@ }, "is-obj": { "version": "1.0.1", - "resolved": "http://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=" }, "is-object": { @@ -6621,7 +6621,7 @@ }, "load-json-file": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "requires": { "graceful-fs": "^4.1.2", @@ -7130,7 +7130,7 @@ }, "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, "minipass": { @@ -7230,7 +7230,7 @@ }, "mkdirp": { "version": "0.5.1", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "requires": { "minimist": "0.0.8" @@ -7238,7 +7238,7 @@ "dependencies": { "minimist": { "version": "0.0.8", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" } } @@ -7432,7 +7432,7 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" }, "got": { @@ -7468,7 +7468,7 @@ }, "p-cancelable": { "version": "0.4.1", - "resolved": "http://registry.npmjs.org/p-cancelable/-/p-cancelable-0.4.1.tgz", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-0.4.1.tgz", "integrity": "sha512-HNa1A8LvB1kie7cERyy21VNeHb2CWJJYqyyC2o3klWFfMGlFmWv2Z7sFgZH8ZiaYL95ydToKTFVXgMV/Os0bBQ==" }, "p-event": { @@ -7592,7 +7592,7 @@ "dependencies": { "file-type": { "version": "3.9.0", - "resolved": "http://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=" } } @@ -7617,7 +7617,7 @@ "dependencies": { "get-stream": { "version": "3.0.0", - "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" }, "pify": { @@ -7674,7 +7674,7 @@ }, "get-stream": { "version": "2.3.1", - "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", "integrity": "sha1-Xzj5PzRgCWZu4BUKBUFn+Rvdld4=", "requires": { "object-assign": "^4.0.1", @@ -7704,7 +7704,7 @@ "dependencies": { "get-stream": { "version": "3.0.0", - "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" } } @@ -7744,7 +7744,7 @@ }, "pify": { "version": "2.3.0", - "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" }, "prepend-http": { @@ -7849,7 +7849,7 @@ }, "readable-stream": { "version": "1.1.14", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "requires": { "core-util-is": "~1.0.0", @@ -8227,7 +8227,7 @@ }, "onetime": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=" }, "open": { @@ -8379,7 +8379,7 @@ }, "p-is-promise": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/p-is-promise/-/p-is-promise-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-1.1.0.tgz", "integrity": "sha1-nJRWmJ6fZYgBewQ01WCXZ1w9oF4=" }, "p-limit": { @@ -8860,7 +8860,7 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" } } @@ -9144,7 +9144,7 @@ "dependencies": { "file-type": { "version": "3.9.0", - "resolved": "http://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=" } } @@ -9169,7 +9169,7 @@ "dependencies": { "get-stream": { "version": "3.0.0", - "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" }, "pify": { @@ -9207,7 +9207,7 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" } } @@ -9259,7 +9259,7 @@ }, "get-stream": { "version": "2.3.1", - "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", "integrity": "sha1-Xzj5PzRgCWZu4BUKBUFn+Rvdld4=", "requires": { "object-assign": "^4.0.1", @@ -9289,7 +9289,7 @@ "dependencies": { "get-stream": { "version": "3.0.0", - "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" } } @@ -9477,7 +9477,7 @@ }, "query-string": { "version": "5.1.1", - "resolved": "http://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", "integrity": "sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==", "requires": { "decode-uri-component": "^0.2.0", @@ -9616,7 +9616,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", @@ -10484,7 +10484,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "requires": { "ansi-regex": "^2.0.0" @@ -10509,7 +10509,7 @@ }, "strip-dirs": { "version": "1.1.1", - "resolved": "http://registry.npmjs.org/strip-dirs/-/strip-dirs-1.1.1.tgz", + "resolved": "https://registry.npmjs.org/strip-dirs/-/strip-dirs-1.1.1.tgz", "integrity": "sha1-lgu9EoeETzl1pFWKoQOoJV4kVqA=", "requires": { "chalk": "^1.0.0", @@ -10767,7 +10767,7 @@ }, "through": { "version": "2.3.8", - "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" }, "through2": { @@ -10786,7 +10786,7 @@ }, "readable-stream": { "version": "1.0.34", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "requires": { "core-util-is": "~1.0.0", diff --git a/package.json b/package.json index 428cdf482..a74f68460 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "yazl": "^2.5.1" }, "devDependencies": { - "electron": "9.0.0-beta.24", + "electron": "9.0.0", "electron-builder": "22.6.0", "electron-packager": "14.2.1", "electron-rebuild": "1.10.1", diff --git a/src/public/app/services/ws.js b/src/public/app/services/ws.js index e20ecc5fb..3ddb70bc9 100644 --- a/src/public/app/services/ws.js +++ b/src/public/app/services/ws.js @@ -229,7 +229,7 @@ subscribeToMessages(message => { async function processSyncRows(syncRows) { const missingNoteIds = []; - for (const {id, entityName, entity} of syncRows) { + for (const {entityName, entity} of syncRows) { if (entityName === 'branches' && !(entity.parentNoteId in treeCache.notes)) { missingNoteIds.push(entity.parentNoteId); } diff --git a/src/public/app/services/zoom.js b/src/public/app/services/zoom.js index ad7faa08b..d5b4b4eb6 100644 --- a/src/public/app/services/zoom.js +++ b/src/public/app/services/zoom.js @@ -9,9 +9,11 @@ class ZoomService extends Component { constructor() { super(); - options.initializedPromise.then(() => { - this.setZoomFactor(options.getFloat('zoomFactor')); - }); + if (utils.isElectron()) { + options.initializedPromise.then(() => { + this.setZoomFactor(options.getFloat('zoomFactor')); + }); + } } setZoomFactor(zoomFactor) { diff --git a/src/public/app/widgets/component.js b/src/public/app/widgets/component.js index 9ca210248..4e042c559 100644 --- a/src/public/app/widgets/component.js +++ b/src/public/app/widgets/component.js @@ -82,6 +82,10 @@ export default class Component { let release; try { + if (this.mutex.isLocked()) { + console.debug("Mutex locked for", this.constructor.name); + } + release = await this.mutex.acquire(); await fun.call(this, data); @@ -93,4 +97,4 @@ export default class Component { } } } -} \ No newline at end of file +} diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.js index 6b690f13c..1fca3ae91 100644 --- a/src/public/app/widgets/note_detail.js +++ b/src/public/app/widgets/note_detail.js @@ -308,9 +308,10 @@ export default class NoteDetailWidget extends TabAwareWidget { return; } - await noteCreateService.createNote(note.noteId, { + // without await as this otherwise causes deadlock through component mutex + noteCreateService.createNote(note.noteId, { isProtected: note.isProtected, saveSelection: true }); } -} \ No newline at end of file +}