I have already close handler error when using lsp-lens.nvim, I found code stop timer first and then close. I assumed that the stop function closes the timer and when we stop the timer, it gets stopped again.
-- Create a timer handle (implementation detail: uv_timer_t).
local timer = vim.loop.new_timer()
local i = 0
-- Waits 1000ms, then repeats every 750ms until timer:close().
timer:start(1000, 750, function()
print('timer invoked! i='..tostring(i))
if i > 4 then
timer:close() -- Always close handles to avoid leaks.
end
i = i + 1
end)
print('sleeping');
I have already close handler error when using
lsp-lens.nvim
, I found code stop timer first and then close. I assumed that the stop function closes the timer and when we stop the timer, it gets stopped again.So I tried to remove the stop code and it worked.
And I also found the latest document about it: https://neovim.io/doc/user/lua.html#lua-loop this example shows that we don't need timer:stop() anymore