History

fix(cloud): spawn relay client without shell

Julius Marminge committed 5 months ago

Commit 0ccb1ef1 parent 06440773 files · +17 −12Browse files

Unified · Split

3 files
  1. apps/server/src/cloud/ManagedEndpointRuntime.test.ts +7 −2
  2. apps/server/src/cloud/ManagedEndpointRuntime.ts +9 −9
  3. packages/shared/src/relayClient.ts +1 −1
apps/server/src/cloud/ManagedEndpointRuntime.test.ts+7−2
@@ -106,12 +106,17 @@ describe("CloudManagedEndpointRuntime", () => { · 105 unmodified lines
106106
107107 expect(spawned.map((command) => command.command)).toEqual(["cloudflared", "cloudflared"]);
108108 expect(spawned.map((command) => command.args)).toEqual([
109− ["tunnel", "run", "--token", "token-1"],
110− ["tunnel", "run", "--token", "token-2"],
109+ ["tunnel", "run"],
110+ ["tunnel", "run"],
111+ ]);
112+ expect(spawned.map((command) => command.options.env?.TUNNEL_TOKEN)).toEqual([
113+ "token-1",
114+ "token-2",
111115 ]);
112116 expect(spawned.map((command) => command.options.stdout)).toEqual(["ignore", "ignore"]);
113117 expect(spawned.map((command) => command.options.stderr)).toEqual(["ignore", "ignore"]);
114118 expect(spawned.map((command) => command.options.detached)).toEqual([false, false]);
119+ expect(spawned.map((command) => command.options.shell)).toEqual([false, false]);
115120 expect(killed).toEqual([100, 101]);
116121 expect(stopped).toEqual({ status: "disabled" });
117122 }),
apps/server/src/cloud/ManagedEndpointRuntime.ts+9−9
@@ -185,16 +185,16 @@ export const makeCloudManagedEndpointRuntime = Effect.gen(function* () { · 184 unmodified lines
185185 const connectorScope = yield* Scope.make("sequential");
186186 const child = yield* spawner
187187 .spawn(
188− ChildProcess.make(
189− executable.executablePath,
190− ["tunnel", "run", "--token", config.connectorToken],
191− {
192− detached: false,
193− shell: process.platform === "win32",
194− stderr: "ignore",
195− stdout: "ignore",
188+ ChildProcess.make(executable.executablePath, ["tunnel", "run"], {
189+ detached: false,
190+ env: {
191+ ...process.env,
192+ TUNNEL_TOKEN: config.connectorToken,
196193 },
197− ),
194+ shell: false,
195+ stderr: "ignore",
196+ stdout: "ignore",
197+ }),
198198 )
199199 .pipe(
200200 Effect.provideService(Scope.Scope, connectorScope),
packages/shared/src/relayClient.ts+1−1
@@ -292,7 +292,7 @@ export const makeCloudflaredRelayClient = Effect.fn("cloudflared.make")(function · 291 unmodified lines
292292 ) {
293293 const child = yield* spawner.spawn(
294294 ChildProcess.make(command, args, {
295− shell: platform === "win32",
295+ shell: false,
296296 stdout: "ignore",
297297 stderr: "ignore",
298298 }),