diff --git a/src/cli/handlers/cloud.ts b/src/cli/handlers/cloud.ts index 4fcf68ece..d8bf79fa6 100644 --- a/src/cli/handlers/cloud.ts +++ b/src/cli/handlers/cloud.ts @@ -231,18 +231,28 @@ function getCloudRawArgs(): string[] { async function runCsCloud(args: string[]): Promise { const bin = await ensureCsCloud() + + // Optimize spawn call to match direct execution performance const child = spawn(bin, args, { - stdio: "inherit", + stdio: ["ignore", "inherit", "inherit"], windowsHide: false, - env: { ...process.env, CSC_CLOUD_INVOKER: "csc" }, + env: process.env, + shell: false, + detached: false, }) + const code = await new Promise((resolve) => { child.on("error", (err) => { console.error(`failed to run cs-cloud: ${err.message}`) resolve(1) }) child.on("exit", resolve) + child.on("disconnect", () => { + console.error(`cs-cloud disconnected unexpectedly`) + resolve(1) + }) }) + process.exit(code ?? 1) } @@ -253,6 +263,5 @@ export async function cloudHandler(rawArgs: string[]): Promise { process.exit(1) } - await ensureCsCloud() await runCsCloud(args) }