Daemon: scope relaxed systemd probes to install flows

This commit is contained in:
Vincent Koc
2026-03-07 16:45:18 -08:00
parent fcb990e369
commit 0d66834f94
6 changed files with 102 additions and 19 deletions

View File

@@ -123,6 +123,21 @@ describe("maybeInstallDaemon", () => {
expect(serviceInstall).toHaveBeenCalledTimes(1);
});
it("rethrows install probe failures that are not the known non-fatal Linux systemd cases", async () => {
serviceIsLoaded.mockRejectedValueOnce(
new Error("systemctl is-enabled unavailable: read-only file system"),
);
await expect(
maybeInstallDaemon({
runtime: { log: vi.fn(), error: vi.fn(), exit: vi.fn() },
port: 18789,
}),
).rejects.toThrow("systemctl is-enabled unavailable: read-only file system");
expect(serviceInstall).not.toHaveBeenCalled();
});
it("continues the WSL2 daemon install flow when service status probe reports systemd unavailability", async () => {
serviceIsLoaded.mockRejectedValueOnce(
new Error("systemctl --user unavailable: Failed to connect to bus: No medium found"),

View File

@@ -1,6 +1,7 @@
import { withProgress } from "../cli/progress.js";
import { loadConfig } from "../config/config.js";
import { resolveGatewayService } from "../daemon/service.js";
import { isNonFatalSystemdInstallProbeError } from "../daemon/systemd.js";
import type { RuntimeEnv } from "../runtime.js";
import { note } from "../terminal/note.js";
import { confirm, select } from "./configure.shared.js";
@@ -23,7 +24,10 @@ export async function maybeInstallDaemon(params: {
let loaded = false;
try {
loaded = await service.isLoaded({ env: process.env });
} catch {
} catch (error) {
if (!isNonFatalSystemdInstallProbeError(error)) {
throw error;
}
loaded = false;
}
let shouldCheckLinger = false;