polyipseity / obsidian-modules

Load JavaScript and related languages like TypeScript modules from the vault and the Internet.
GNU Affero General Public License v3.0
68 stars 4 forks source link

[BUG] Changelog opens every time I open Obsidian, even though there is no update #4

Closed FeralFlora closed 1 year ago

FeralFlora commented 1 year ago

What the title says: Every time I open Obsidian (regardless of any actual update) there are one or even two tabs with the Modules changelog. These were not there when I closed Obsidian.

polyipseity commented 1 year ago

Is there anything that prevents the successful saving of .obsidian/plugins/modules/data.json? Open the developer console (Ctrl+Shift+I or Cmd+Shift+I), click the "Console" tab, change some Modules settings, and see if any message pops up.

Also, if you have set up any syncing solution, check if the syncing solution is messing around with .obsidian/plugins/modules/data.json. Assuming you are using the latest version (2.1.0), then you should see "lastReadChangelogVersion": "2.1.0" inside .obsidian/plugins/modules/data.json, which suppresses opening the changelog.

Lastly, please send me the content of .obsidian/plugins/modules/data.json.

As a temporary solution, you can disable "Open changelog on update" in the plugin settings.

FeralFlora commented 1 year ago

@polyipseity Hey, thanks for responding.

First, I get this error in this changelog on every startup:

Error: Too many pending tasks in queue emit
    at Vb.acquire (plugin:modules:18:2462)
    at eval (plugin:modules:30144:219472)
    at new Promise (<anonymous>)
    at nZe.emit (plugin:modules:30144:219442)
    at l.cache (plugin:modules:30148:23074)
    at eval (plugin:modules:30148:22367)
    at Array.map (<anonymous>)
    at P (plugin:modules:30148:22349)
    at eval (plugin:modules:30144:219546)
    at Array.map (<anonymous>)
eval @ plugin:modules:30148

When I tried to change a setting, I got this error (which seems to be the same one):

Plugin:modules:18 Uncaught (in promise) Error: Too many pending tasks in queue emit
    at Vb.acquire (plugin:modules:18:2462)
    at eval (plugin:modules:30144:219472)
    at new Promise (<anonymous>)
    at nZe.emit (plugin:modules:30144:219442)
    at l.cache (plugin:modules:30148:23074)
    at eval (plugin:modules:30148:22367)
    at Array.map (<anonymous>)
    at P (plugin:modules:30148:22349)
    at eval (plugin:modules:30144:219546)
    at Array.map (<anonymous>)
Vb.acquire @ plugin:modules:18
eval @ plugin:modules:30144
emit @ plugin:modules:30144
cache @ plugin:modules:30148
eval @ plugin:modules:30148
P @ plugin:modules:30148
eval @ plugin:modules:30144
eval @ plugin:modules:30144
eval @ plugin:modules:18
Vb._promiseTry @ plugin:modules:18
Ye @ plugin:modules:18
Vb.acquire @ plugin:modules:18
eval @ plugin:modules:30144
emit @ plugin:modules:30144
eval @ plugin:modules:30146
eval @ plugin:modules:30146
eval @ plugin:modules:30144
eval @ plugin:modules:30144
eval @ plugin:modules:18
Vb._promiseTry @ plugin:modules:18
Ye @ plugin:modules:18
Vb.acquire @ plugin:modules:18
eval @ plugin:modules:30144
emit @ plugin:modules:30144
mutate @ plugin:modules:30146

Regarding sync, I am using git for that, but the .obsidian config folder is in gitignore.

I am on version 2.1.0, but data.json says "lastReadChangelogVersion": "2.0.0".

The full content of data.json is:

{
  "enableExternalLinks": true,
  "errorNoticeTimeout": 0,
  "exposeInternalModules": true,
  "importTimeout": 10,
  "language": "",
  "lastReadChangelogVersion": "2.0.0",
  "markdownCodeBlockLanguagesToLoad": [
    "JS",
    "TS",
    "JavaScript",
    "TypeScript"
  ],
  "noticeTimeout": 5,
  "openChangelogOnUpdate": true,
  "preloadedExternalLinks": [],
  "preloadingRules": [
    "+/\\.m?[jt]s(?:\\.md)?$/iu"
  ],
  "recovery": {},
  "requireName": "require"
}
polyipseity commented 1 year ago

Hmm, can you see if replacing maxPending:1e3 with maxPending:Infinity inside main.js helps? There should be only one instance of maxPending:1e3. I am thinking that your vault has over 1000 files, causing this error.

FeralFlora commented 1 year ago

Hmm, can you see if replacing maxPending:1e3 with maxPending:Infinity inside main.js helps? There should be only one instance of maxPending:1e3. I am thinking that your vault has over 1000 files, causing this error.

I don't have more than 1000 files, at least not MD files. I have 841 MD plus images, primarily. Altogether, it's probably more than 1000 files. Changing that line got rid of the error, and seems to have resolved the issue, since data.json now reflects the right version. What are the consequences of this change?

polyipseity commented 1 year ago

Oh, it just does not like suddenly knowing the existence of more than 1000 files (including attachments) at once. When you start Obsidian, the plugin suddenly knows all of your files in the vault at once, causing it to error out.

Changing 1e3, which means 1000, to Infinity removes the limit, causing it to succeed. This should not impact the performance or memory too much. By the time it does matter, your probably have way too many files for Obsidian to handle anyway.

I will release the fix some time later.

StefanoRausch commented 1 year ago

I can confirm @FeralFlora discovery and thanks for fixing the issue, @polyipseity!

Your workaround with maxPending:Infinity works.

polyipseity commented 1 year ago

@FeralFlora, @StefanoRausch: Released in 2.2.0.

StefanoRausch commented 1 year ago

I can confirm that the issue is gone. 🙂