Skip to content

Commit 25b3475

Browse files
authored
fix(async): propagate errors occurring within block_on() calls (#286)
1 parent 3223396 commit 25b3475

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

lua/plenary/async/util.lua

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,12 @@ M.block_on = function(async_function, timeout)
2929
ret = { ... }
3030
end)
3131

32-
local function check()
33-
if stat == false then
34-
error("Blocking on future failed " .. unpack(ret))
35-
end
36-
return stat == true
37-
end
32+
vim.wait(timeout or 2000, function()
33+
return stat ~= nil
34+
end, 20, false)
3835

39-
if not vim.wait(timeout or 2000, check, 20, false) then
40-
error "Blocking on future timed out or was interrupted"
36+
if stat == false then
37+
error(string.format("Blocking on future timed out or was interrupted.\n%s", unpack(ret)))
4138
end
4239

4340
return unpack(ret)

0 commit comments

Comments
 (0)