Skip to content

Commit

Permalink
catch JSON stringify error, #4310
Browse files Browse the repository at this point in the history
  • Loading branch information
zadam committed Oct 5, 2023
1 parent 1dc3faf commit 86d6286
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 78 deletions.
144 changes: 72 additions & 72 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"jimp": "0.22.10",
"joplin-turndown-plugin-gfm": "1.0.12",
"jsdom": "22.1.0",
"marked": "9.0.3",
"marked": "9.1.0",
"mime-types": "2.1.35",
"multer": "1.4.5-lts.1",
"node-abi": "3.47.0",
Expand All @@ -78,11 +78,11 @@
"react": "18.2.0",
"react-dom": "18.2.0",
"request": "2.88.2",
"rimraf": "5.0.1",
"rimraf": "5.0.5",
"safe-compare": "1.1.4",
"sanitize-filename": "1.6.3",
"sanitize-html": "2.11.0",
"sax": "1.2.4",
"sax": "1.3.0",
"semver": "7.5.4",
"serve-favicon": "2.5.0",
"session-file-store": "1.5.0",
Expand All @@ -97,7 +97,7 @@
},
"devDependencies": {
"cross-env": "7.0.3",
"electron": "25.8.3",
"electron": "25.9.0",
"electron-builder": "24.6.4",
"electron-packager": "17.1.2",
"electron-rebuild": "3.2.9",
Expand Down
9 changes: 7 additions & 2 deletions src/services/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,14 @@ async function pullChanges(syncContext) {
if (entityChanges.length === 0) {
break;
} else {
const sizeInKb = Math.round(JSON.stringify(resp).length / 1024);
try { // https://github.com/zadam/trilium/issues/4310
const sizeInKb = Math.round(JSON.stringify(resp).length / 1024);

log.info(`Sync ${logMarkerId}: Pulled ${entityChanges.length} changes in ${sizeInKb} KB, starting at entityChangeId=${lastSyncedPull} in ${pulledDate - startDate}ms and applied them in ${Date.now() - pulledDate}ms, ${outstandingPullCount} outstanding pulls`);
log.info(`Sync ${logMarkerId}: Pulled ${entityChanges.length} changes in ${sizeInKb} KB, starting at entityChangeId=${lastSyncedPull} in ${pulledDate - startDate}ms and applied them in ${Date.now() - pulledDate}ms, ${outstandingPullCount} outstanding pulls`);
}
catch (e) {
log.error(`Error occurred ${e.message} ${e.stack}`);
}
}
}

Expand Down

0 comments on commit 86d6286

Please sign in to comment.