Skip to content

Commit d114376

Browse files
authored
fix(installer): timeout schema download after 5s (#1374)
Closes #1361.
1 parent db58ec7 commit d114376

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lua/mason-core/installer/registry/schemas.lua

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
local Result = require "mason-core.result"
22
local _ = require "mason-core.functional"
3+
local a = require "mason-core.async"
34
local expr = require "mason-core.installer.registry.expr"
45
local fetch = require "mason-core.fetch"
56
local log = require "mason-core.log"
@@ -56,7 +57,15 @@ function M.download(ctx, spec, purl, source)
5657
ctx.fs:mkdir "mason-schemas"
5758

5859
if interpolated_schemas.lsp then
59-
try(download_lsp_schema(ctx, interpolated_schemas.lsp))
60+
try(a.wait_first {
61+
function()
62+
return download_lsp_schema(ctx, interpolated_schemas.lsp)
63+
end,
64+
function()
65+
a.sleep(5000)
66+
return Result.failure "Schema download timed out."
67+
end,
68+
})
6069
end
6170
end)
6271
end

0 commit comments

Comments
 (0)