liamcain/obsidian-things-logbook

Sync no longer working

Opened this issue ยท 5 comments

Before Submitting: Double-check that you are running the latest version of the plugin. The bug might have already been fixed ๐Ÿ˜„

Describe the bug

Syncing is no longer working.

Steps to reproduce

  1. Select "Things Logbook: Sync" from the command palette.

Expected behavior

  1. I expect to see a notification that sync completed, but no message appears.
  2. I expect that newly completed tasks in Things appear in my daily note, but nothing is added.

Screenshots

Here's a snapshot from the developer's console:

[Things Logbook] fetching tasks from sqlite db...
VM411:674 [Things Logbook] fetched 98 tasks from sqlite db
VM411:689 [Things Logbook] fetching checklist items from sqlite db...
VM411:694 [Things Logbook] fetched 0 checklist items from sqlite db
app.js:1 Uncaught (in promise) RangeError: Invalid line number 34 in 33-line document
    at t.e.line (app.js:1)
    at zu (app.js:1)
    at t.replaceRange (app.js:1)
    at updateSection (eval at <anonymous> (app.js:1), <anonymous>:383:20)
    at async ThingsLogbookPlugin.syncLogbook (eval at <anonymous> (app.js:1), <anonymous>:790:13)

Environment (please specify)

OS

macOS 11.6.1

Obsidian Version (e.g. v0.10.6)

0.13.6

Theme (if applicable):

If the bug is visual, please provide the name of the Community Theme you're using.

Interesting, sounds like this broke from the Obsidian update. I'll take a look this weekend.

Have the same issue but it doesn't happen every time.
If I rename today's daily note and let the sync create a new one, sync starts to work again for some time.
But I couldn't figure out what causes the crash yet

I think this has something to do with trying to update the current note that it is open in the editor. For some reason the length of the document is returned incorrectly and causes the above error, which stops sync.

I recently noticed this as well and believe it is caused in part by the new editor experience.

2022-01-14_10-15-01

I can confirm the source file does have 9 lines in it.
I was able to track it down to the following bit of source code and added some logging and it appears logbook sync does say to replace to line 9.
https://github.com/liamcain/obsidian-things-logbook/blob/main/src/textUtils.ts#L75

I think the bug may be in the new editor itself and found that disabling the new editor does in fact resolve the issue.

Reached out on discord and, in theory, there will be a fix for it in the next insider build.
https://discord.com/channels/686053708261228577/840286264964022302/931627709149380669

Until then I would recommend temporarily disabling the new editor to run the sync command and then turning it back on after it syncs.