Skip to content

Commit f503346

Browse files
authored
fix(async): always check channel state (#1351)
1 parent 0276793 commit f503346

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lua/mason-core/async/init.lua

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,14 @@ local function wait(suspend_fns, mode)
176176
for i, suspend_fn in ipairs(suspend_fns) do
177177
thread_cancellations[i] = exports.run(suspend_fn, function(success, result)
178178
completed = completed + 1
179+
if channel:is_closed() then
180+
return
181+
end
179182
if not success then
180-
if not channel:is_closed() then
181-
cancel()
182-
channel:send(false, result)
183-
results = nil
184-
thread_cancellations = {}
185-
end
183+
cancel()
184+
channel:send(false, result)
185+
results = nil
186+
thread_cancellations = {}
186187
else
187188
results[i] = result
188189
if mode == "first" or completed >= count then

0 commit comments

Comments
 (0)