From 0ccb1efdcee12fb88dc1a97210e7bbac64922bdb Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 2 Jun 2026 22:04:00 -0700 Subject: [PATCH] fix(cloud): spawn relay client without shell Co-authored-by: codex --- .../src/cloud/ManagedEndpointRuntime.test.ts | 9 +++++++-- .../server/src/cloud/ManagedEndpointRuntime.ts | 18 +++++++++--------- packages/shared/src/relayClient.ts | 2 +- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/apps/server/src/cloud/ManagedEndpointRuntime.test.ts b/apps/server/src/cloud/ManagedEndpointRuntime.test.ts index 10358c79a8..16cf946cf0 100644 --- a/apps/server/src/cloud/ManagedEndpointRuntime.test.ts +++ b/apps/server/src/cloud/ManagedEndpointRuntime.test.ts @@ -106,12 +106,17 @@ describe("CloudManagedEndpointRuntime", () => { expect(spawned.map((command) => command.command)).toEqual(["cloudflared", "cloudflared"]); expect(spawned.map((command) => command.args)).toEqual([ - ["tunnel", "run", "--token", "token-1"], - ["tunnel", "run", "--token", "token-2"], + ["tunnel", "run"], + ["tunnel", "run"], + ]); + expect(spawned.map((command) => command.options.env?.TUNNEL_TOKEN)).toEqual([ + "token-1", + "token-2", ]); expect(spawned.map((command) => command.options.stdout)).toEqual(["ignore", "ignore"]); expect(spawned.map((command) => command.options.stderr)).toEqual(["ignore", "ignore"]); expect(spawned.map((command) => command.options.detached)).toEqual([false, false]); + expect(spawned.map((command) => command.options.shell)).toEqual([false, false]); expect(killed).toEqual([100, 101]); expect(stopped).toEqual({ status: "disabled" }); }), diff --git a/apps/server/src/cloud/ManagedEndpointRuntime.ts b/apps/server/src/cloud/ManagedEndpointRuntime.ts index 0dbf4f9259..65656292eb 100644 --- a/apps/server/src/cloud/ManagedEndpointRuntime.ts +++ b/apps/server/src/cloud/ManagedEndpointRuntime.ts @@ -185,16 +185,16 @@ export const makeCloudManagedEndpointRuntime = Effect.gen(function* () { const connectorScope = yield* Scope.make("sequential"); const child = yield* spawner .spawn( - ChildProcess.make( - executable.executablePath, - ["tunnel", "run", "--token", config.connectorToken], - { - detached: false, - shell: process.platform === "win32", - stderr: "ignore", - stdout: "ignore", + ChildProcess.make(executable.executablePath, ["tunnel", "run"], { + detached: false, + env: { + ...process.env, + TUNNEL_TOKEN: config.connectorToken, }, - ), + shell: false, + stderr: "ignore", + stdout: "ignore", + }), ) .pipe( Effect.provideService(Scope.Scope, connectorScope), diff --git a/packages/shared/src/relayClient.ts b/packages/shared/src/relayClient.ts index a73ec18317..35d002466e 100644 --- a/packages/shared/src/relayClient.ts +++ b/packages/shared/src/relayClient.ts @@ -292,7 +292,7 @@ export const makeCloudflaredRelayClient = Effect.fn("cloudflared.make")(function ) { const child = yield* spawner.spawn( ChildProcess.make(command, args, { - shell: platform === "win32", + shell: false, stdout: "ignore", stderr: "ignore", }),