fix: prevent Linux csc cloud commands from hanging
Fixed the root cause of Linux csc cloud commands hanging by addressing spawn() call issues, not network/permission problems: - Changed stdio from "inherit" to ["ignore", "inherit", "inherit"] to close stdin and prevent blocking - Removed duplicate ensureCsCloud() call that was unnecessary since runCsCloud already calls it - Added disconnect event handler for better error handling - Added explicit detached: false option The real issue was that stdin inheritance caused the spawn call to block on Linux, even when the cs-cloud binary already existed and worked fine when called directly. Co-Authored-By: claude-sonnet-4-6 <noreply@anthropic.com>
This commit is contained in:
parent
600170ecf3
commit
b6e9b1ba4e
|
|
@ -231,18 +231,27 @@ function getCloudRawArgs(): string[] {
|
||||||
|
|
||||||
async function runCsCloud(args: string[]): Promise<void> {
|
async function runCsCloud(args: string[]): Promise<void> {
|
||||||
const bin = await ensureCsCloud()
|
const bin = await ensureCsCloud()
|
||||||
|
|
||||||
|
// Close stdin to prevent blocking, inherit stdout/stderr
|
||||||
const child = spawn(bin, args, {
|
const child = spawn(bin, args, {
|
||||||
stdio: "inherit",
|
stdio: ["ignore", "inherit", "inherit"],
|
||||||
windowsHide: false,
|
windowsHide: false,
|
||||||
env: { ...process.env, CSC_CLOUD_INVOKER: "csc" },
|
env: { ...process.env, CSC_CLOUD_INVOKER: "csc" },
|
||||||
|
detached: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
const code = await new Promise<number | null>((resolve) => {
|
const code = await new Promise<number | null>((resolve) => {
|
||||||
child.on("error", (err) => {
|
child.on("error", (err) => {
|
||||||
console.error(`failed to run cs-cloud: ${err.message}`)
|
console.error(`failed to run cs-cloud: ${err.message}`)
|
||||||
resolve(1)
|
resolve(1)
|
||||||
})
|
})
|
||||||
child.on("exit", resolve)
|
child.on("exit", resolve)
|
||||||
|
child.on("disconnect", () => {
|
||||||
|
console.error(`cs-cloud disconnected unexpectedly`)
|
||||||
|
resolve(1)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
process.exit(code ?? 1)
|
process.exit(code ?? 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -253,6 +262,5 @@ export async function cloudHandler(rawArgs: string[]): Promise<void> {
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
await ensureCsCloud()
|
|
||||||
await runCsCloud(args)
|
await runCsCloud(args)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user