Skip to content

Commit

Permalink
skip precompile workload if localhost cannot be resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Dec 24, 2024
1 parent d13c17c commit 21c245c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/HTTP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,14 @@ end

# only run if precompiling
if VERSION >= v"1.9.0-0" && ccall(:jl_generating_output, Cint, ()) == 1
include("precompile.jl")
do_precompile = true
try
Sockets.getalladdrinfo("localhost")
catch ex
@debug "Skipping precompilation workload because localhost cannot be resolved. Check firewall settings" exception=(ex,catch_backtrace())
do_precompile = false
end
do_precompile && include("precompile.jl")
end

end # module
4 changes: 2 additions & 2 deletions src/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ try
# listenany allows changing port if that one is already in use, so check the actual port
_port = HTTP.port(server)
url = "https://localhost:$_port"

env = ["JULIA_NO_VERIFY_HOSTS" => "localhost",
"JULIA_SSL_NO_VERIFY_HOSTS" => nothing,
"JULIA_ALWAYS_VERIFY_HOSTS" => nothing]

withenv(env...) do
@compile_workload begin
HTTP.get(url);
Expand Down

0 comments on commit 21c245c

Please sign in to comment.