Skip to content

Recursive symlinks can cause project discovery to fail #1185

Open
@thecrypticace

Description

@thecrypticace

Projects that contain symlinks back to a parent directory can cause project discovery to briefly freeze or even error.

I think the source of this behavior is fast-glob. It just doesn't handle this case at all when you still need to resolve symlinks. It walks the symlink and stops after some level of recursion / depth. There's no concept of an "filter entry" callback that we could use to prevent traversal by realpath. A possible solution to this would be to run two traversals one that doesn't follow symlinks and one that does with an expanded ignore list but that would be quite wasteful for the general case.

The problem with the repeated symlink recursion is that there's a chance that you'll can hit the path length limit before you hit the recursion limit and project discovery throw an error because of the length of the path passed to a filesystem API causes it to throw.

  • Windows (normal): 260 characters
  • Windows (long paths enabled registry and app binary): ~32,767 characters
  • Linux: 4,096 characters
  • macOS: 1,024 characters

This information can be discovered about an environment like so:

# Windows (registry check only)
# 0 = 260, 1 = 32,767
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled'

# Linux and macOS
getconf PATH_MAX /

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions