Start the Windows bundle when the network is disconnected

The launcher asked /api/health through Invoke-WebRequest, which resolves the
system proxy or PAC script before it looks at the URL; with no network every
probe timed out and the launcher killed a healthy local process after two
minutes and reported that Luminary had not started. Both launchers now probe
127.0.0.1 over a raw TCP socket, which uses no proxy, DNS or certificate store,
and the app window is started with --no-proxy-server.
This commit is contained in:
2026-12-01 12:13:54 +00:00
parent 7aef2e37bf
commit a7ba0d2e87
4 changed files with 58 additions and 7 deletions
+30 -3
View File
@@ -96,11 +96,34 @@ function Read-Runtime {
try { return Get-Content -Raw -LiteralPath $runtimeFile | ConvertFrom-Json } catch { return $null }
}
# Loopback liveness probe.
#
# Invoke-WebRequest goes through WinINET, which resolves the system proxy (a PAC
# script or WPAD) before it looks at the URL. On a machine with no network that
# lookup can block for far longer than -TimeoutSec, so every probe timed out and
# the launcher killed a healthy local server: the app "would not start" offline.
# A raw request over TCP to 127.0.0.1 uses no proxy, DNS or certificate store, so
# start-up behaves the same with or without a connection.
function Test-Health([int]$port) {
$client = $null
try {
$response = Invoke-WebRequest -UseBasicParsing -TimeoutSec 2 -Uri ("http://127.0.0.1:{0}/api/health" -f $port)
return ($response.StatusCode -eq 200)
} catch { return $false }
$client = New-Object System.Net.Sockets.TcpClient
$connect = $client.ConnectAsync([System.Net.IPAddress]::Loopback, $port)
if (-not $connect.Wait(2000)) { return $false }
$client.ReceiveTimeout = 3000
$stream = $client.GetStream()
$request = [System.Text.Encoding]::ASCII.GetBytes((
"GET /api/health HTTP/1.0`r`nHost: 127.0.0.1:{0}`r`nConnection: close`r`n`r`n" -f $port))
$stream.Write($request, 0, $request.Length)
$stream.Flush()
$reader = New-Object System.IO.StreamReader($stream, [System.Text.Encoding]::ASCII)
$status = $reader.ReadLine()
return ($status -match '^HTTP/1\.[01] 200\b')
} catch {
return $false
} finally {
if ($client) { $client.Close() }
}
}
function Test-Process([int]$processId) {
@@ -183,12 +206,16 @@ function Open-App([string]$url) {
$profile = Join-Path (Get-DataDir) 'window-profile'
try {
New-Item -ItemType Directory -Force -Path $profile | Out-Null
# --no-proxy-server: the window only ever loads 127.0.0.1. A proxy or PAC
# script set on the machine must not be able to intercept (or stall) it
# when the network is down.
Start-Process -FilePath $exe -ArgumentList @(
"--app=$url",
"--user-data-dir=$profile",
'--window-size=1500,950',
'--no-first-run',
'--no-default-browser-check',
'--no-proxy-server',
'--disable-features=Translate'
) | Out-Null
} catch {