From f5033463bb911a136e577fc6f339328f162e2b4a Mon Sep 17 00:00:00 2001 From: William Boman Date: Tue, 13 Jun 2023 15:45:07 +0200 Subject: fix(async): always check channel state (#1351) --- lua/mason-core/async/init.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lua') diff --git a/lua/mason-core/async/init.lua b/lua/mason-core/async/init.lua index 50c84a71..63d4ec94 100644 --- a/lua/mason-core/async/init.lua +++ b/lua/mason-core/async/init.lua @@ -176,13 +176,14 @@ local function wait(suspend_fns, mode) for i, suspend_fn in ipairs(suspend_fns) do thread_cancellations[i] = exports.run(suspend_fn, function(success, result) completed = completed + 1 + if channel:is_closed() then + return + end if not success then - if not channel:is_closed() then - cancel() - channel:send(false, result) - results = nil - thread_cancellations = {} - end + cancel() + channel:send(false, result) + results = nil + thread_cancellations = {} else results[i] = result if mode == "first" or completed >= count then -- cgit v1.2.3-70-g09d2