fix(lua): close vim.defer_fn() timer if vim.schedule() failed (#37647)

Problem:
Using vim.defer_fn() just before Nvim exit leaks luv handles.

Solution:
Make vim.schedule() return an error message if scheduling failed.
Make vim.defer_fn() close timer if vim.schedule() failed.
This commit is contained in:
zeertzjq
2026-02-01 21:29:19 +08:00
committed by GitHub
parent 0501c5fd09
commit 1906da52db
6 changed files with 41 additions and 11 deletions

View File

@@ -510,8 +510,8 @@ function M.new_session(keep, ...)
end
if delta > 500 then
print(
('Nvim session %s took %d milliseconds to exit\n'):format(test_id, delta)
.. 'This indicates a likely problem with the test even if it passed!\n'
('\nNvim session %s took %d milliseconds to exit\n'):format(test_id, delta)
.. 'This indicates a likely problem with the test even if it passed!'
)
io.stdout:flush()
end