Open zpeters opened 2 years ago
I am not too fluent with javascript, but after digging around i found the root of the issue. I dont understand why, but im narrowing it down.
In the following code in main.tsx
is what appears to cause the delays. In my thought process there is something in checkStatus that is blocking when it should by async?
logseq.DB.onChanged(async () => {
setTimeout(() => {
checkStatus()
}, 1000)
})
I can confirm this issue. A single keystroke will cause the following entries in the console
3index.8e262b56.js:87 Checking status...
index.8e262b56.js:80 [faiz:] === git status {stdout: ' M journals/2022_06_06.md\n M logseq/pages-metadata…n action research.edn"\n?? journals/2022_06_07.md\n', stderr: '', exitCode: 0}
index.8e262b56.js:87 Need save {stdout: ' M journals/2022_06_06.md\n M logseq/pages-metadata…n action research.edn"\n?? journals/2022_06_07.md\n', stderr: '', exitCode: 0}
index.8e262b56.js:80 [faiz:] === git status {stdout: ' M journals/2022_06_06.md\n M logseq/pages-metadata…n action research.edn"\n?? journals/2022_06_07.md\n', stderr: '', exitCode: 0}
index.8e262b56.js:87 Need save {stdout: ' M journals/2022_06_06.md\n M logseq/pages-metadata…n action research.edn"\n?? journals/2022_06_07.md\n', stderr: '', exitCode: 0}
index.8e262b56.js:80 [faiz:] === git status {stdout: ' M journals/2022_06_06.md\n M logseq/pages-metadata…n action research.edn"\n?? journals/2022_06_07.md\n', stderr: '', exitCode: 0}
index.8e262b56.js:87 Need save {stdout: ' M journals/2022_06_06.md\n M logseq/pages-metadata…n action research.edn"\n?? journals/2022_06_07.md\n', stderr: '', exitCode: 0}
The 3index
line means that the entry is repeated 3 times.
As with @zpeters, I am not familiar with logseq plugin system, but it looks like logseq.DB.onChanged
gets triggered at each keystroke. Calling checkStatus
every single time might be the culprit.
Happy to test fixes. Your plugin is a fundamental part of my workflow.
Not sure about reason, but can confirm performance was unacceptable (on Mac) with plugin enabled. Happy to test if needed.
Version 1.2.0 added the checkWhenDBChanged
option to manually disable listening to logseq.DB.onChanged
.
In addition, I have submitted the issue to logseq.
You can test whether the problem is resolved.
Thank you @haydenull !
Thanks, @haydenull, for the quick fix! Hopefully they fix it upstream as well.
I started experiencing "slowdowns" in logseq that i couldn't explain. As i was filing a bug with their main github repo, i think i narrowed down the issue to this plugin. Below is my experience and how i reproduce the issue on my system. This is the same on an x86 or m1 mac. I have not tested this on Windows yet.
What happened?
After logseq has been open for a few minutes (to avoid any "startup" issues) it will randomly "slow down". Sometimes there is lag in navigating between pages, but this is most apparent when just typing. There will be a delay of several seconds between typing a letter and it appearing
Reproduce the bug
I have development experience, but have not worked on a logseq plugin yet. Im happy to provide more testing and potentially a PR if i can get some guidance on getting started to with plugin development
Thanks for the great plugin! Im very motivated to help get this fixed because it is a very important part of my workflow.