Fix destroyed components staying in the output when a delayed cleanup errors (#103)

Co-authored-by: centau <83140718+centau@users.noreply.github.com>
This commit is contained in:
Kaan 2026-10-22 14:56:56 +03:00 • committed by GitHub
parent a75e3ee843
commit 673105c51a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 59 additions and 3 deletions

View file

@ -101,9 +101,10 @@ local function indexes<K, V, Obj>(
scope.value = nil -- set to nil for the `scope.value ~= v` check
if scope.timeout == nil then
scope.timeout = timeout(scope.delay, function() -- todo: possible redundant updates
scope.destroy()
local ok, err = pcall(scope.destroy)
scopes[i] = nil
update_output()
if not ok then error(err, 0) end
end)
end
end

View file

@ -50,9 +50,10 @@ local function switch_map<K, Obj>(
else
if scope.timeout == nil then
scope.timeout = timeout(scope.delay, function()
scope.destroy()
local ok, err = pcall(scope.destroy)
scopes[k] = nil
update_output()
if not ok then error(err, 0) end
end)
end
end

View file

@ -111,9 +111,10 @@ local function values<K, V, Obj>(
scope.index = nil -- set to nil for the `scope.index ~= i` check
if scope.timeout == nil then
scope.timeout = timeout(scope.delay, function() -- todo: possible redundant updates
scope.destroy()
local ok, err = pcall(scope.destroy)
scopes[v] = nil
update_output()
if not ok then error(err, 0) end
end)
end
end