Skip to content

Commit 6ab7d2f

Browse files
authored
fix: close the timer to avoid memory leak (#421)
1 parent 2fb6416 commit 6ab7d2f

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lua/opencode/util.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,10 @@ function M.format_cost(c)
352352
end
353353

354354
function M.debounce(func, delay)
355-
local timer = nil
355+
local timer ---@type uv.uv_timer_t?
356356
return function(...)
357-
if timer then
358-
timer:stop()
357+
if timer and not timer:is_closing() then
358+
timer:close()
359359
end
360360
local args = { ... }
361361
timer = vim.defer_fn(function()

0 commit comments

Comments
 (0)