Skip to content

fix(treesitter): check buffer validity before enabling features#70

Merged
mehalter merged 1 commit into
AstroNvim:mainfrom
gogongxt:fix-invalid-buffer-check
Apr 13, 2026
Merged

fix(treesitter): check buffer validity before enabling features#70
mehalter merged 1 commit into
AstroNvim:mainfrom
gogongxt:fix-invalid-buffer-check

Conversation

@gogongxt
Copy link
Copy Markdown
Contributor

When treesitter parser installation is triggered asynchronously (e.g., via auto_install), the buffer may be deleted before the installation completes and the callback is executed. This can happen when using plugins like flatten.nvim that open files in a guest process and then delete buffers before sending them to the host.

This race condition results in an "Invalid buffer id" error when the async callback tries to enable treesitter features on a buffer that no longer exists.

📑 Description

📖 Additional Information

When treesitter parser installation is triggered asynchronously (e.g.,
via auto_install), the buffer may be deleted before the installation
completes and the callback is executed. This can happen when using
plugins like flatten.nvim that open files in a guest process and then
delete buffers before sending them to the host.

This race condition results in an "Invalid buffer id" error when the
async callback tries to enable treesitter features on a buffer that
no longer exists.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gogongxt
Copy link
Copy Markdown
Contributor Author

@mehalter @astronvimbot Hello. Please review the pr. I met a treesitter error when merged to AstroNvim V6. Finally found the problem is async treesitter.

@mehalter mehalter merged commit 4763bc9 into AstroNvim:main Apr 13, 2026
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.

2 participants