Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
improved error handling
zadambb81f110dd3a
diff --git a/package-lock.json b/package-lock.jsonindex 8166cca97e..7884129c21 100644--- a/package-lock.json+++ b/package-lock.json@@ -12,7 +12,7 @@"dependencies": {"@braintree/sanitize-url": "6.0.4","@electron/remote": "2.0.11",- "@excalidraw/excalidraw": "0.16.0",+ "@excalidraw/excalidraw": "0.16.1","archiver": "5.3.1","async-mutex": "0.4.0","axios": "1.5.0",@@ -22,7 +22,7 @@"compression": "1.7.4","cookie-parser": "1.4.6","csurf": "1.11.0",- "dayjs": "1.11.9",+ "dayjs": "1.11.10","dayjs-plugin-utc": "0.1.2","debounce": "1.2.1","ejs": "3.1.9",@@ -70,7 +70,7 @@"tmp": "0.2.1","turndown": "7.1.2","unescape": "1.0.1",- "ws": "8.14.1",+ "ws": "8.14.2","xml2js": "0.6.2","yauzl": "2.10.0"},@@ -83,7 +83,7 @@"electron-builder": "24.6.4","electron-packager": "17.1.2","electron-rebuild": "3.2.9",- "eslint": "8.48.0",+ "eslint": "8.49.0","eslint-config-airbnb-base": "15.0.0","eslint-config-prettier": "9.0.0","eslint-plugin-import": "2.28.1",@@ -447,18 +447,18 @@}},"node_modules/@eslint/js": {- "version": "8.48.0",- "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.48.0.tgz",- "integrity": "sha512-ZSjtmelB7IJfWD2Fvb7+Z+ChTIKWq6kjda95fLcQKNS5aheVHn4IkfgRQE3sIIzTcSLwLcLZUD9UBt+V7+h+Pw==",+ "version": "8.49.0",+ "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.49.0.tgz",+ "integrity": "sha512-1S8uAY/MTJqVx0SC4epBq+N2yhuwtNwLbJYNZyhL2pO1ZVKn5HFXav5T41Ryzy9K9V7ZId2JB2oy/W4aCd9/2w==","dev": true,"engines": {"node": "^12.22.0 || ^14.17.0 || >=16.0.0"}},"node_modules/@excalidraw/excalidraw": {- "version": "0.16.0",- "resolved": "https://registry.npmjs.org/@excalidraw/excalidraw/-/excalidraw-0.16.0.tgz",- "integrity": "sha512-9DGTKBWs1MPA6FbBg443Q77qGYeNJIyDWoQWVEMG2NsMfHHot8I5zM4jXvi9Eb31n8BqA1jqGhF8E9FVeprMOA==",+ "version": "0.16.1",+ "resolved": "https://registry.npmjs.org/@excalidraw/excalidraw/-/excalidraw-0.16.1.tgz",+ "integrity": "sha512-4zirHk7dNx6SVq2jQmYOLliqAa1h3WPVqHM5qtJyhD769VsOqwlkopAcnZMb3G1PeIMm6cf2F31quS5MVqvoOQ==","peerDependencies": {"react": "^17.0.2 || ^18.2.0","react-dom": "^17.0.2 || ^18.2.0"@@ -471,9 +471,9 @@"dev": true},"node_modules/@humanwhocodes/config-array": {- "version": "0.11.10",- "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz",- "integrity": "sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==",+ "version": "0.11.11",+ "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.11.tgz",+ "integrity": "sha512-N2brEuAadi0CcdeMXUkhbZB84eskAc8MEX1By6qEchoVywSgXPIjou4rYsl0V3Hj0ZnuGycGCjdNgockbzeWNA==","dev": true,"dependencies": {"@humanwhocodes/object-schema": "^1.2.1",@@ -3836,9 +3836,9 @@}},"node_modules/dayjs": {- "version": "1.11.9",- "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.9.tgz",- "integrity": "sha512-QvzAURSbQ0pKdIye2txOzNaHmxtUBXerpY0FJsFXUMKbIZeFm5ht1LS/jFsrncjnmtv8HsG0W2g6c0zUjZWmpA=="+ "version": "1.11.10",+ "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz",+ "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ=="},"node_modules/dayjs-plugin-utc": {"version": "0.1.2",@@ -5001,16 +5001,16 @@}},"node_modules/eslint": {- "version": "8.48.0",- "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.48.0.tgz",- "integrity": "sha512-sb6DLeIuRXxeM1YljSe1KEx9/YYeZFQWcV8Rq9HfigmdDEugjLEVEa1ozDjL6YDjBpQHPJxJzze+alxi4T3OLg==",+ "version": "8.49.0",+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.49.0.tgz",+ "integrity": "sha512-jw03ENfm6VJI0jA9U+8H5zfl5b+FvuU3YYvZRdZHOlU2ggJkxrlkJH4HcDrZpj6YwD8kuYqvQM8LyesoazrSOQ==","dev": true,"dependencies": {"@eslint-community/eslint-utils": "^4.2.0","@eslint-community/regexpp": "^4.6.1","@eslint/eslintrc": "^2.1.2",- "@eslint/js": "8.48.0",- "@humanwhocodes/config-array": "^0.11.10",+ "@eslint/js": "8.49.0",+ "@humanwhocodes/config-array": "^0.11.11","@humanwhocodes/module-importer": "^1.0.1","@nodelib/fs.walk": "^1.2.8","ajv": "^6.12.4",@@ -13124,9 +13124,9 @@}},"node_modules/ws": {- "version": "8.14.1",- "resolved": "https://registry.npmjs.org/ws/-/ws-8.14.1.tgz",- "integrity": "sha512-4OOseMUq8AzRBI/7SLMUwO+FEDnguetSk7KMb1sHwvF2w2Wv5Hoj0nlifx8vtGsftE/jWHojPy8sMMzYLJ2G/A==",+ "version": "8.14.2",+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz",+ "integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==","engines": {"node": ">=10.0.0"},@@ -13572,15 +13572,15 @@}},"@eslint/js": {- "version": "8.48.0",- "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.48.0.tgz",- "integrity": "sha512-ZSjtmelB7IJfWD2Fvb7+Z+ChTIKWq6kjda95fLcQKNS5aheVHn4IkfgRQE3sIIzTcSLwLcLZUD9UBt+V7+h+Pw==",+ "version": "8.49.0",+ "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.49.0.tgz",+ "integrity": "sha512-1S8uAY/MTJqVx0SC4epBq+N2yhuwtNwLbJYNZyhL2pO1ZVKn5HFXav5T41Ryzy9K9V7ZId2JB2oy/W4aCd9/2w==","dev": true},"@excalidraw/excalidraw": {- "version": "0.16.0",- "resolved": "https://registry.npmjs.org/@excalidraw/excalidraw/-/excalidraw-0.16.0.tgz",- "integrity": "sha512-9DGTKBWs1MPA6FbBg443Q77qGYeNJIyDWoQWVEMG2NsMfHHot8I5zM4jXvi9Eb31n8BqA1jqGhF8E9FVeprMOA==",+ "version": "0.16.1",+ "resolved": "https://registry.npmjs.org/@excalidraw/excalidraw/-/excalidraw-0.16.1.tgz",+ "integrity": "sha512-4zirHk7dNx6SVq2jQmYOLliqAa1h3WPVqHM5qtJyhD769VsOqwlkopAcnZMb3G1PeIMm6cf2F31quS5MVqvoOQ==","requires": {}},"@gar/promisify": {@@ -13590,9 +13590,9 @@"dev": true},"@humanwhocodes/config-array": {- "version": "0.11.10",- "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz",- "integrity": "sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==",+ "version": "0.11.11",+ "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.11.tgz",+ "integrity": "sha512-N2brEuAadi0CcdeMXUkhbZB84eskAc8MEX1By6qEchoVywSgXPIjou4rYsl0V3Hj0ZnuGycGCjdNgockbzeWNA==","dev": true,"requires": {"@humanwhocodes/object-schema": "^1.2.1",@@ -16215,9 +16215,9 @@}},"dayjs": {- "version": "1.11.9",- "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.9.tgz",- "integrity": "sha512-QvzAURSbQ0pKdIye2txOzNaHmxtUBXerpY0FJsFXUMKbIZeFm5ht1LS/jFsrncjnmtv8HsG0W2g6c0zUjZWmpA=="+ "version": "1.11.10",+ "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz",+ "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ=="},"dayjs-plugin-utc": {"version": "0.1.2",@@ -17103,16 +17103,16 @@"dev": true},"eslint": {- "version": "8.48.0",- "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.48.0.tgz",- "integrity": "sha512-sb6DLeIuRXxeM1YljSe1KEx9/YYeZFQWcV8Rq9HfigmdDEugjLEVEa1ozDjL6YDjBpQHPJxJzze+alxi4T3OLg==",+ "version": "8.49.0",+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.49.0.tgz",+ "integrity": "sha512-jw03ENfm6VJI0jA9U+8H5zfl5b+FvuU3YYvZRdZHOlU2ggJkxrlkJH4HcDrZpj6YwD8kuYqvQM8LyesoazrSOQ==","dev": true,"requires": {"@eslint-community/eslint-utils": "^4.2.0","@eslint-community/regexpp": "^4.6.1","@eslint/eslintrc": "^2.1.2",- "@eslint/js": "8.48.0",- "@humanwhocodes/config-array": "^0.11.10",+ "@eslint/js": "8.49.0",+ "@humanwhocodes/config-array": "^0.11.11","@humanwhocodes/module-importer": "^1.0.1","@nodelib/fs.walk": "^1.2.8","ajv": "^6.12.4",@@ -23120,9 +23120,9 @@}},"ws": {- "version": "8.14.1",- "resolved": "https://registry.npmjs.org/ws/-/ws-8.14.1.tgz",- "integrity": "sha512-4OOseMUq8AzRBI/7SLMUwO+FEDnguetSk7KMb1sHwvF2w2Wv5Hoj0nlifx8vtGsftE/jWHojPy8sMMzYLJ2G/A==",+ "version": "8.14.2",+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz",+ "integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==","requires": {}},"xhr": {diff --git a/package.json b/package.jsonindex 31a593ae4a..50ee703e9d 100644--- a/package.json+++ b/package.json@@ -33,7 +33,7 @@"dependencies": {"@braintree/sanitize-url": "6.0.4","@electron/remote": "2.0.11",- "@excalidraw/excalidraw": "0.16.0",+ "@excalidraw/excalidraw": "0.16.1","archiver": "5.3.1","async-mutex": "0.4.0","axios": "1.5.0",@@ -43,7 +43,7 @@"compression": "1.7.4","cookie-parser": "1.4.6","csurf": "1.11.0",- "dayjs": "1.11.9",+ "dayjs": "1.11.10","dayjs-plugin-utc": "0.1.2","debounce": "1.2.1","ejs": "3.1.9",@@ -91,7 +91,7 @@"tmp": "0.2.1","turndown": "7.1.2","unescape": "1.0.1",- "ws": "8.14.1",+ "ws": "8.14.2","xml2js": "0.6.2","yauzl": "2.10.0"},@@ -101,7 +101,7 @@"electron-builder": "24.6.4","electron-packager": "17.1.2","electron-rebuild": "3.2.9",- "eslint": "8.48.0",+ "eslint": "8.49.0","eslint-config-airbnb-base": "15.0.0","eslint-config-prettier": "9.0.0","eslint-plugin-import": "2.28.1",diff --git a/src/services/notes.js b/src/services/notes.jsindex 94f101433e..0183aff988 100644--- a/src/services/notes.js+++ b/src/services/notes.js@@ -895,6 +895,10 @@ async function asyncPostProcessContent(note, content) {// all keys should be replaced by the corresponding valuesfunction replaceByMap(str, mapObj) {+ if (!mapObj) {+ return str;+ }+const re = new RegExp(Object.keys(mapObj).join("|"),"g");return str.replace(re, matched => mapObj[matched]);diff --git a/src/services/setup.js b/src/services/setup.jsindex 02a3ef32eb..be1d0df059 100644--- a/src/services/setup.js+++ b/src/services/setup.js@@ -93,7 +93,7 @@ async function setupSyncFromSyncServer(syncServerHost, syncProxy, password) {return { result: 'success' };}catch (e) {- log.error(`Sync failed: ${e.message}`);+ log.error(`Sync failed: '${e.message}', stack: ${e.stack}`);return {result: 'failure',diff --git a/src/services/sync.js b/src/services/sync.jsindex 1cfc8e2e82..75ee820186 100644--- a/src/services/sync.js+++ b/src/services/sync.js@@ -71,8 +71,7 @@ async function sync() {};}else {- log.info(`sync failed: ${e.message}-stack: ${e.stack}`);+ log.info(`Sync failed: '${e.message}', stack: ${e.stack}`);ws.syncFailed();diff --git a/src/services/sync_update.js b/src/services/sync_update.jsindex c7f81afd76..950709e4a8 100644--- a/src/services/sync_update.js+++ b/src/services/sync_update.js@@ -46,6 +46,10 @@ function updateNormalEntity(remoteEC, remoteEntityRow, instanceId) {}if (!localEC || localEC.utcDateChanged <= remoteEC.utcDateChanged) {+ if (!remoteEntityRow) {+ throw new Error(`Empty entity row for: ${JSON.stringify(remoteEC)}`);+ }+if (remoteEC.entityName === 'blobs' && remoteEntityRow.content !== null) {// we always use a Buffer object which is different from normal saving - there we use a simple string type for// "string notes". The problem is that in general, it's not possible to detect whether a blob content@@ -59,10 +63,6 @@ function updateNormalEntity(remoteEC, remoteEntityRow, instanceId) {}}- if (!remoteEntityRow) {- throw new Error(`Empty entity row for: ${JSON.stringify(remoteEC)}`);- }-sql.replace(remoteEC.entityName, remoteEntityRow);if (!localEC || localEC.utcDateChanged < remoteEC.utcDateChanged) {@@ -81,6 +81,10 @@ function updateNormalEntity(remoteEC, remoteEntityRow, instanceId) {}function updateNoteReordering(remoteEC, remoteEntityRow, instanceId) {+ if (!remoteEntityRow) {+ throw new Error(`Empty note_reordering body for: ${JSON.stringify(remoteEC)}`);+ }+for (const key in remoteEntityRow) {sql.execute("UPDATE branches SET notePosition = ? WHERE branchId = ?", [remoteEntityRow[key], key]);}