Merge pull request #139 from y574444354/fix/linux-cloud-hang

fix: prevent Linux csc cloud commands from hanging
This commit is contained in:
DoSun 2026-05-20 17:06:20 +08:00 committed by GitHub
commit 69ee2ca31e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -231,18 +231,28 @@ function getCloudRawArgs(): string[] {
async function runCsCloud(args: string[]): Promise<void> {
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<number | null>((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<void> {
process.exit(1)
}
await ensureCsCloud()
await runCsCloud(args)
}