silverbulletmd / silverbullet

The hackable notebook
https://silverbullet.md
MIT License
2.04k stars 141 forks source link

"Duplicate key" error causes "Page changed elsewhere, reloading" often #803

Closed simone-viozzi closed 3 months ago

simone-viozzi commented 3 months ago

Full log:

silverbullet-1  | Duplicate key ["idx","anchor","<path to note>$ENV","<path to note>"] in batchSet, skipping
silverbullet-1  | Duplicate key ["ridx","<path to note>","anchor","<path to note>$ENV"] in batchSet, skipping
silverbullet-1  | Duplicate key ["idx","anchor","<path to note>$ENV","<path to note>"] in batchSet, skipping
silverbullet-1  | Duplicate key ["ridx","<path to note>","anchor","<path to note>$ENV"] in batchSet, skipping
silverbullet-1  | Duplicate key ["idx","anchor","<path to note>$ENV","<path to note>"] in batchSet, skipping
silverbullet-1  | Duplicate key ["ridx","<path to note>","anchor","<path to note>$ENV"] in batchSet, skipping
silverbullet-1  | Duplicate key ["idx","anchor","<path to note>$ENV","<path to note>"] in batchSet, skipping
silverbullet-1  | Duplicate key ["ridx","<path to note>","anchor","<path to note>$ENV"] in batchSet, skipping
silverbullet-1  | Duplicate key ["idx","anchor","<path to note>$ENV","<path to note>"] in batchSet, skipping
silverbullet-1  | Duplicate key ["ridx","<path to note>","anchor","<path to note>$ENV"] in batchSet, skipping
silverbullet-1  | Duplicate key ["idx","anchor","<path to note>$ENV","<path to note>"] in batchSet, skipping
silverbullet-1  | Duplicate key ["ridx","<path to note>","anchor","<path to note>$ENV"] in batchSet, skipping
silverbullet-1  | Duplicate key ["idx","anchor","<path to note>$ENV","<path to note>"] in batchSet, skipping
silverbullet-1  | Duplicate key ["ridx","<path to note>","anchor","<path to note>$ENV"] in batchSet, skipping
silverbullet-1  | Duplicate key ["idx","anchor","<path to note>$ENV","<path to note>"] in batchSet, skipping
silverbullet-1  | Duplicate key ["ridx","<path to note>","anchor","<path to note>$ENV"] in batchSet, skipping
silverbullet-1  | Duplicate key ["idx","anchor","<path to note>$ENV","<path to note>"] in batchSet, skipping
silverbullet-1  | Duplicate key ["ridx","<path to note>","anchor","<path to note>$ENV"] in batchSet, skipping

every time silverbullet reloads the page, the cursor jumps to the top, and some edits are lost

Tried doing "space reindex", "reload ui" but the error persists,

every couple of edits, the page reloads itself with this error in the logs.

What other info are needed to track this issue? The note I'm editing is fairly big, ~15 pages of Microsoft Word, is this a problem?

kadengubler commented 3 months ago

I am having the same issue where a message shows at the top saying "Page changed elsewhere, reloading." I don't see anything related to a duplicate key in my logs though.

I see the issue on all pages and most are small without much content.

I also find that I don't see the issue when I am in sync mode.

zefhemel commented 3 months ago

I recently moved setup (to a higher latency one) and I see the same issue now, looking to address it.

simone-viozzi commented 3 months ago

My setup is on docker, on WSL, on Windows. So everything is pretty slow.

I will try sync mode to mitigate the issue.

Any idea about the duplicate key errors in the log? Those are specific to a single note. The "Page changed elsewhere, reloading." message starting to appear on more and more notes.

zefhemel commented 3 months ago

What's happening is that you have multiple anchors with the same name in your document, it looks like $ENV in multiple places. Likely you don't intend to create anchors (https://silverbullet.md/Markdown/Anchors) at all, but they're there. Honestly, this should break like this so I'll fix that.

simone-viozzi commented 3 months ago

ohh i see, yes i have some $ENV in the text, so the "duplicated key" and the "Page changed elsewhere" are unrelated.

good to know.

you can close this if you want, and maybe reopen another for the "Page changed elsewhere, reloading". Because it happens a lot, but most of the time the logs looks completely fine.

zefhemel commented 3 months ago

I hope the reload is is addressed on the current edge builds, if you could try that that'd be great: https://community.silverbullet.md/t/living-on-the-edge-builds/27