Skip to content

Commit

Permalink
fix(tasks): gracefully handle callbacks after cancel
Browse files Browse the repository at this point in the history
If a callback returns after a task is already cancelled, we should
gracefully handle it by not attempting to set the result of the task
since it is already set.

See #15
  • Loading branch information
rcarriga committed May 2, 2024
1 parent d874322 commit 8765cbc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lua/nio/tasks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ function nio.tasks.run(func, cb)
end

local function close_task(result, err)
if not tasks[co] then
return
end
tasks[co] = nil
if err then
future.set_error(err)
Expand Down

0 comments on commit 8765cbc

Please sign in to comment.