Skip to content

Conversation

@zinefer
Copy link
Contributor

@zinefer zinefer commented Jul 27, 2025

Why

My development box has a symlink from home into my mounts directory: /home/zinefer/code => /mnt/code

The getOrCreateFolderTestItem function expects a cache hit and if it does not find one, it will continue to recurse forever at the filesystem root.

If I open a project, say, /home/zinefer/code/github.com/vitest-dev/vscode, it will result in a call chain like so:

[depth=0] normalizedFolder: /mnt/code/github.com/vitest-dev/vscode/some/test/path
[depth=0] folderItems: /home/zinefer/code/github.com/vitest-dev/vscode
[depth=1] normalizedFolder: /mnt/code/github.com/vitest-dev/vscode/some/test
[depth=1] folderItems: /home/zinefer/code/github.com/vitest-dev/vscode
[depth=2] normalizedFolder: /mnt/code/github.com/vitest-dev/vscode/some
[depth=2] folderItems: /home/zinefer/code/github.com/vitest-dev/vscode
[depth=3] normalizedFolder: /mnt/code/github.com/vitest-dev/vscode
[depth=3] folderItems: /home/zinefer/code/github.com/vitest-dev/vscode
[depth=4] normalizedFolder: /mnt/code/github.com/vitest-dev
[depth=4] folderItems: /home/zinefer/code/github.com/vitest-dev/vscode
[depth=5] normalizedFolder: /mnt/code/github.com
[depth=5] folderItems: /home/zinefer/code/github.com/vitest-dev/vscode
[depth=6] normalizedFolder: /mnt/code
[depth=6] folderItems: /home/zinefer/code/github.com/vitest-dev/vscode
[depth=7] normalizedFolder: /mnt
[depth=7] folderItems: /home/zinefer/code/github.com/vitest-dev/vscode
[depth=8] normalizedFolder: /
[depth=8] folderItems: /home/zinefer/code/github.com/vitest-dev/vscode
[depth=9] normalizedFolder: /
[depth=9] folderItems: /home/zinefer/code/github.com/vitest-dev/vscode
[depth=10] normalizedFolder: /
[depth=10] folderItems: /home/zinefer/code/github.com/vitest-dev/vscode
{ Infinite }

What

I've replaced the lstat based symlink resolution with realpath. This will resolve the symlink in the upper part of the path and allow for a cache hit inside getOrCreateFolderTestItem.

I've also added a runtime check to detect the infinite loop, prevent it and log an error.

@zinefer zinefer changed the title Bugfix: Resolve ancestral symlinks fix: Resolve ancestral symlinks Jul 27, 2025
@zinefer zinefer changed the title fix: Resolve ancestral symlinks fix: resolve ancestral symlinks Jul 27, 2025
@zinefer
Copy link
Contributor Author

zinefer commented Jul 30, 2025

I noticed I had a failing workflow - Is that something I need to be concerned about ?

@sheremet-va sheremet-va merged commit 5b55cf8 into vitest-dev:main Jul 31, 2025
1 of 2 checks passed
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.

2 participants