zadam / trilium

Build your personal knowledge base with Trilium Notes
GNU Affero General Public License v3.0
27.2k stars 1.9k forks source link

Deleting a note sometimes causes an error in the main process #2073

Closed abitofevrything closed 3 years ago

abitofevrything commented 3 years ago

Trilium version: master@f3959cf2aada016b4b96fc097e7d6fee9185b123 Log file: trilium-2021-07-21.log

Deleting a note sometimes causes the following exception to occur:

Uncaught Exception:
TypeError: Cannot read property 'getContent' of undefined
    at Function.<anonymous> (.../trilium/src/services/notes.js:365:46)
    at Function.sqliteTransaction (.../trilium/node_modules/better-sqlite3/lib/methods/transactio...:24)
    at Object.transactional (.../trilium/src/services/sql.js:238:52)
    at Timeout._onTimeout (.../trilium/src/services/notes.js:361:17)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)

How to reproduce:

  1. Open devtools in the electron app
  2. Go to network tab > throttling and set to 'Offline'
  3. Create a new note, then delete it
  4. Go back to network tab > throttling and reset to 'No throttling'
  5. After a couple of seconds the error will appear

This seems to be due to notes being deleted while note images are still being downloaded.

zadam commented 3 years ago

Hi, thanks for report, fixed.