KevinBatdorf / obsidian-raycast

Raycast extension with commands for the note taking app Obsidian.
MIT License
106 stars 19 forks source link

JS heap out of memory when using detail view #19

Closed Dzar34 closed 2 years ago

Dzar34 commented 2 years ago

Hello, thanks for building this! Unfortunately, every time I attempt to search my vault, I can see a list of my notes for a split second, then I get an error. Message copied below. Thanks for any help!

Error: Worker terminated due to reaching memory limit: JS heap out of memory

__node_internal_captureLargerStackTrace:errors:464:5 NodeError:errors:371:5 Worker.[kOnExit]:worker:279:26 Worker..onexit:worker:201:20

marcjulianschwarz commented 2 years ago

Hello @Dzar34,

looks like you have too many notes for the Detail View as it will have to load the content for every note (unfortunately, will have to investigate if there is a better solution). How many notes does your vault contain? Try turning off the Detail View in the extensions preferences.

If that doesn’t help I will take a look at it. And I will try to find a solution for it to work with any amount of notes.

Dzar34 commented 2 years ago

Thanks for responding! I did turn off detail view, but I am still getting the same error. I have 10,650 notes 😳 I may just be an outlier!

marcjulianschwarz commented 2 years ago

I was able to reproduce the error by creating a vault with 10.000 notes each with 100 words. It looks like the notes load just fine (independent of detail view state).

Logging the current memory usage reveals that the extension uses about 0.06 GB which should not be enough to reach the memory limit of node. Another thing that I noticed was that everything worked as long as I was slowly going through the search results. The second I held down an arrow key (thus going through the results very fast) it reached the memory limit. The same thing happens when using the search, going through different queries fast will fill result in an error but it won't crash when I search slowly.

Help from someone with more experience is greatly appreciated as I currently don't know how to fix this.

marcjulianschwarz commented 2 years ago

Found a way to get this fixed. Seems like Raycast can't handle rendering for more than 1k-3k list items. With the newest commit only 1000 items will be rendered and they change based on the search query.

You can try out the new version by cloning the repository, running npm install and then starting the extension with npm run dev. Let me know when everything is working.

marcjulianschwarz commented 2 years ago

This has been fixed with version 1.6.0 which has now been released.

Dzar34 commented 2 years ago

It works great!! Thanks so much for creating this and working on a fix. I love it!