Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't follow recursive symlinks during project discovery #1270

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

thecrypticace
Copy link
Contributor

Project discovery is done by crawling the workspace with fast-glob looking for CSS files, JS/TS config files, Sass/Less files, etc…

A major problem with this approach though is that fast-glob crawls the filesystem and traverses into symlinked directories. If the symlink points back to a parent folder the crawler may cause a handful of issues:

  • An infinite traversal loop
  • Out of memory crashes (causing the server to restart repeatedly)
  • A rather long discovery time (10s+)
  • Errors because of file path length limits (esp on Windows)

I've rewritten the traversal to use fdir + picomatch which appears to avoid all of these issues. The implementation is fairly simple with the exception of some necessary tweaks to how we interpret the excludes setting from VSCode (basically just needed to create some new patterns from the old ones to match directories and files better).

I've also implemented a timeout that will cause fdir to cancel the project search if it takes too long (this is currently hardcoded to 15s).

All existing tests pass as well as an additional test that previously timed out due to the use of recursive symlinks. This PR is going to require extensive testing on Windows with network shares, mapped drives, etc…

Fixes #1056
Fixes #1185

@thecrypticace thecrypticace force-pushed the fix/recursive-symlinks branch from 729d00f to b7e06e3 Compare March 20, 2025 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Recursive symlinks can cause project discovery to fail The Code Helper process constantly uses 100%-200% CPU
1 participant