Skip to content

Commit 9db9aad

Browse files
skip precompile workload if localhost cannot be resolved (#1210)
1 parent d13c17c commit 9db9aad

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/HTTP.jl

+8-1
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,14 @@ end
633633

634634
# only run if precompiling
635635
if VERSION >= v"1.9.0-0" && ccall(:jl_generating_output, Cint, ()) == 1
636-
include("precompile.jl")
636+
do_precompile = true
637+
try
638+
Sockets.getalladdrinfo("localhost")
639+
catch ex
640+
@debug "Skipping precompilation workload because localhost cannot be resolved. Check firewall settings" exception=(ex,catch_backtrace())
641+
do_precompile = false
642+
end
643+
do_precompile && include("precompile.jl")
637644
end
638645

639646
end # module

src/precompile.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ try
2626
# listenany allows changing port if that one is already in use, so check the actual port
2727
_port = HTTP.port(server)
2828
url = "https://localhost:$_port"
29-
29+
3030
env = ["JULIA_NO_VERIFY_HOSTS" => "localhost",
3131
"JULIA_SSL_NO_VERIFY_HOSTS" => nothing,
3232
"JULIA_ALWAYS_VERIFY_HOSTS" => nothing]
33-
33+
3434
withenv(env...) do
3535
@compile_workload begin
3636
HTTP.get(url);

0 commit comments

Comments
 (0)