From 62568f6d764f3e9a1c5e43c298bc9be4fb718e44 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Thu, 5 Nov 2026 19:26:12 +0100 Subject: [PATCH] fix: stop the windows bootstrap on a silent server --- install.ps1 | 6 +++++- tests/test_install.py | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/install.ps1 b/install.ps1 index 9261c6ee4..3662a3748 100644 --- a/install.ps1 +++ b/install.ps1 @@ -42,7 +42,11 @@ } $temporary = Join-Path ([IO.Path]::GetTempPath()) ("retrobios-install-{0}.py" -f [Guid]::NewGuid()) try { - Invoke-WebRequest -Uri $uri -OutFile $temporary -UseBasicParsing + # A server that takes the connection and never answers (a + # captive portal, a proxy) held the window forever with no + # line: the wait for an answer stops after 30 s, as curl's + # --connect-timeout in install.sh. + Invoke-WebRequest -Uri $uri -OutFile $temporary -UseBasicParsing -TimeoutSec 30 } catch { # The raw WebException read as a crash and named no next step. throw ("The installer could not be downloaded from {0}: {1} " + diff --git a/tests/test_install.py b/tests/test_install.py index c1f5e6b99..f878dc20e 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -2807,6 +2807,29 @@ class APyLauncherWithoutARuntimeIsPassed(unittest.TestCase): self.assertIn("installer ran", proc.stdout) +@unittest.skipUnless(shutil.which("pwsh"), "needs PowerShell") +class APowerShellDownloadThatNeverAnswersEnds(unittest.TestCase): + """Invoke-WebRequest had no timeout: behind a server that takes the + connection and never answers, the window waited forever with no line.""" + + def test_a_silent_server_ends_on_the_network_advice(self): + folder = Path(_tempdir(self)) + shutil.copy(REPO_ROOT / "install.ps1", folder / "install.ps1") + with socket.socket() as listener: + listener.bind(("127.0.0.1", 0)) + listener.listen(4) + port = listener.getsockname()[1] + started = time.monotonic() + proc = subprocess.run( + ["pwsh", "-NoProfile", "-File", str(folder / "install.ps1"), "--check"], + env={**os.environ, + "RETROBIOS_INSTALL_URL": f"https://127.0.0.1:{port}/install.py"}, + capture_output=True, text=True, timeout=150, stdin=subprocess.DEVNULL) + self.assertLess(time.monotonic() - started, 120) + self.assertNotEqual(proc.returncode, 0) + self.assertIn("could not be downloaded", " ".join((proc.stdout + proc.stderr).split())) + + class ThePowerShellWrapperPassesTheStatusOn(unittest.TestCase): """Every non-zero exit became a red "installer failed" exception and code 1: a --check that found work read as a crash, 2 and 130 were lost."""