Skip to content

fix(utils): replace vim.fn.glob with vim.uv.fs_scandir to fix checkhealth hang#15

Merged
asielcabrera merged 2 commits into
mainfrom
fix-glob-blocking
May 11, 2026
Merged

fix(utils): replace vim.fn.glob with vim.uv.fs_scandir to fix checkhealth hang#15
asielcabrera merged 2 commits into
mainfrom
fix-glob-blocking

Conversation

@asielcabrera
Copy link
Copy Markdown
Contributor

Closes #2the actual root cause identified by live testing in Neovim.

Problem

checkhealth swift was hanging at the Project Detection section with a Keyboard Interrupt. The culprit was vim.fn.glob() inside find_pattern_upwards() in utils.lua.

vim.fn.glob() calls the OS readdir() + shell glob expansion synchronously, blocking Neovim's main thread. On macOS, when the current directory tree contains many files (e.g. your home folder or an NFS mount), this can freeze Neovim indefinitely.

Fix

Replaced vim.fn.glob() with vim.uv.fs_scandir() (libuv's native directory scanner) for suffix-based patterns like *.xcworkspace and *.xcodeproj. Also adds a max_depth = 10 guard so the search never walks all the way to /.

Benchmark (headless Neovim, tested locally)

detect_xcode_workspace (find_pattern_upwards *.xcworkspace)   1ms ✅
detect_xcode_project   (find_pattern_upwards *.xcodeproj)     0ms ✅

Also includes

  • A speed test script tests/test_health_speed.lua to catch regressions

…n_upwards

vim.fn.glob can block Neovim for seconds when scanning large directories (e.g. home folder, NFS mounts). Replaced with vim.uv.fs_scandir for suffix patterns (*.xcworkspace, *.xcodeproj). Also adds a max_depth=10 guard to prevent traversal all the way to /.
@asielcabrera asielcabrera merged commit f25918a into main May 11, 2026
6 of 9 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.

[Bug]: checkhealth hangs without any output

1 participant