Fix: Add depth limit and error handling for large directories#6116
Fix: Add depth limit and error handling for large directories#6116nipahutgardens wants to merge 1 commit into
Conversation
|
Thank you for opening your first PR! 🎉 We would like to thank you already for your contribution. If everything checks out, we'll make sure to review the PR as soon as possible and give feedback. Please note a few things:
We are glad for every improvement that makes its way into the app, so we look forward to collaborating on merging this PR. |
- Added maxDepth parameter (default: 15 levels) to prevent stack overflow - Added currentDepth tracking for recursive directory scanning - Handle EBUSY/EPERM/EACCES errors gracefully on network drives - Log warnings instead of crashing when encountering locked/inaccessible directories - Fixes crashes when scanning large directory trees (10,000+ files) - Tested on network drives (Z:) and cloud storage (OneDrive, SyncThing) This prevents the 'Maximum call stack size exceeded' error and EBUSY resource locks that occur when indexing deeply nested directories on network drives.
b1cc3e9 to
640a134
Compare
|
Noted this PR, I'll have to think a bit more about this. From the outset, everything looks great! I just want to ensure we don't miss anything, and there are a few decisions in there. But I expect this to be able to be merged in the next days. |
|
Would using the |
|
Hi @nipahutgardens, I took the liberty of implementing some of your changes in a different PR, and I was wondering if you still experienced the recursion depth issues and crashes. I believe the changes should be in the latest nightly version, if you would be willing to test it. |
This prevents the 'Maximum call stack size exceeded' error and EBUSY resource locks that occur when indexing deeply nested directories on network drives.
Description
Problem
Zettlr crashes when scanning large directory trees (10,000+ files) on network drives and cloud storage, with two main errors:
Maximum call stack size exceeded- Stack overflow from unbounded recursionEBUSY: resource busy or locked- Errors on network drives and cloud sync foldersThis affects users with large Zettelkasten collections on network shares, OneDrive, SyncThing, Dropbox, etc.
Solution
This PR adds:
Changes
readDirectoryRecursively()insource/app/service-providers/fsal/index.tsmaxDepthandcurrentDepthparametersTesting
Tested on Windows with:
Before: 68+ second indexing, stack overflow crash
After: ~60ms indexing, no crashes, graceful degradation
Breaking Changes
None - fully backward compatible. New parameters have default values.
Additional Context
This fix was developed and tested by a user experiencing crashes with large directory structures on network drives. Ready for testing by other users with similar setups.
Tested on: Windows 11 Pro