TriliumNext / Notes

Build your personal knowledge base with TriliumNext Notes
https://triliumnext.github.io/Docs/
GNU Affero General Public License v3.0
842 stars 46 forks source link

(Bug report) Notes not saving #454

Open Subtlemon opened 3 weeks ago

Subtlemon commented 3 weeks ago

TriliumNext Version

0.90.3

What operating system are you using?

Windows

What is your setup?

Local (no sync)

Operating System Version

Windows 11 Home version 23h2

Description

My notes will randomly and silently fail to save. It's inconsistent, but sometimes when I return to the app (often left open, occasionally after restarting the app), my notes will revert to an earlier version, usually losing several hours worth of notetaking, with nothing saved in the revision history. I have tried to create a shortcut for "Force Save Revision" which I use regularly, but it doesn't seem to help.

I've attached the most recent logs from when this happened. I returned to a note I was working on yesterday, wrote some more notes, Force Save Revision, then closed the app. I re-opened the app to check, and my work had disappeared. There's nothing interesting in the frontend console logs.

How can I stop this from happening? Is it possible to implement a "Failed to save" popup when Force Save Revision fails?

Error logs

trilium-2024-09-30.log

SiriusXT commented 3 weeks ago

I did not find any relevant error information in the logs. Additional reports may be needed, including errors on the console and errors in notification messages, so that we can reproduce it.

Subtlemon commented 3 weeks ago

I also can't reliable reproduce it, but it is highly disruptive whenever it happens. I'll try to grab console errors if this happens while the app is open again. How do I find errors in notification messages?

It would also help to understand what the expected data flow is here, to better understand how it could be failing. While I'm writing, is Trilium periodically writing updates to a local database, then infrequently saving backups? If so, are my periodic updates to the local database silently failing? Or is the local database silently crashing and causing Trilium to read the latest backup, which does not contain my latest updates? How can I test either of these assumptions?

eliandoran commented 1 week ago

@Subtlemon , this seems like a really annoying issue, especially since data loss is involved. Have you had this issue re-occur in these two weeks?

My suspicion would be that the CKEditor crashes and you are typing data into the editor, but the editor is not actually sending this data back to Trilium. This happened to me in the past, especially when dealing with copy-pasting bullet points on Linux.

One way to check if this is the case is to check the development console (Ctrl+Shift+I) and look at the list of errors. If the CKEditor broke, you should see an error in there.

process commented 1 week ago

This sounds suspiciously like https://github.com/zadam/trilium/issues/3584 on the original Trilium repo. It matches your idea about CKEditor crashing @eliandoran . I think zadam's last comment is short and relevant enough to copy here in case it's useful:

Ok, I think I managed to fix it. CKEditor has "watchdog" which reinitializes itself after a crash. That was happening, but the problem was that the event listener for the content change was still registered to the old crashed instance and not to the reinitialized one. So the editor component worked, just did not update the notes anymore.

Subtlemon commented 1 week ago

Fortunately (or unfortunately?) this hasn't happened in the last two weeks, but I also haven't been taking notes as often. I assume the console logs will only be interesting (filtered for errors) if the app is open and unable to save, so I'll keep it open as I type for the dual purpose of getting error logs, and minimizing data loss if it happens again.

As a side note, is it possible to implement some sort of warning toast or the like if the editor is unable to send data to Trilium? If this is infeasible in the background updates, can Force Save Revision (or another action I can make a keyboard shortcut for) send a toast to confirm that the data was saved?