Skip to content

[audit] treesitter.lua glibc check still blocks the main loop (fixes #237, see closed #297) - #341

Draft
stanfish06 wants to merge 1 commit into
masterfrom
audit/treesitter-async-glibc-check
Draft

stanfish06 wants to merge 1 commit into
masterfrom
audit/treesitter-async-glibc-check

Conversation

@stanfish06

Copy link
Copy Markdown
Owner

What

get_glibc_version() in lua/config/treesitter.lua still blocks the main loop on every startup and on every :TSSync, via can_auto_install_parsers() → ts_install() / ts_update().

Where

  • lua/config/treesitter.lua:41-73 (new line numbers) — get_glibc_version(), can_auto_install_parsers()
  • called from ts_install() (module load, line 103/129), build_latest_parsers(), and ts_update() (:TSSync)

Why it matters

Issue #237 flagged vim.fn.system("ldd --version 2>&1 | head -n1") as a blocking shell spawn on every startup. PR #297 attempted a fix by swapping it for vim.system({...}):wait(), but :wait() still blocks the calling context synchronously — it doesn't address the actual complaint (startup pays for a subprocess spawn every time, synchronously), which is presumably why it was closed without merging.

In addition, the check was re-run from scratch on every :TSSync even though the host's glibc version never changes within a session.

Fix

  • get_glibc_version() now takes a callback and uses vim.system()'s async callback form (no :wait() anywhere in the check), so it never blocks the main loop.
  • The result is cached (glibc_version_cache) after the first successful/failed check, so subsequent calls (every :TSSync) don't spawn ldd again at all.
  • can_auto_install_parsers(), ts_install(), build_latest_parsers(), and ts_update() are all converted to the matching callback shape. Behavior (notifications, order of operations, the final "restart neovim" message) is preserved exactly, just asynchronously gated.
  • build_latest_parsers()'s own internal mod_async...:wait() (tracked separately by [audit] build_latest_parsers() intends parallel parser builds but :wait() blocks the whole UI serially #325) is untouched — this PR only removes the blocking glibc probe, not the parallel-build serialization.

No nerd font / icon strings were touched.


Generated by Claude Code

PR #297 swapped vim.fn.system() for vim.system():wait(), which still
blocks the main loop synchronously -- it was closed without merging.
This converts get_glibc_version()/can_auto_install_parsers() to a real
callback-based flow using vim.system()'s async callback, so the check
never blocks startup, and caches the result so repeated calls (every
:TSSync) don't re-spawn ldd at all.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019LFuDqrXyPqgBPwWcbd6Kr
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