signals-dashboard: trySpawn resolves only from spawn/error

Synced from the-workshop@3cd8a0c6a1e24864d746fedb1f2f7ee4f3b17603. Round-4 review: remove the success timeout that could report an unconfirmed launch as launched:true; Node guarantees one of spawn/error fires.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 26faf13e-639c-4a21-ac05-c0dc2bff7c62
This commit is contained in:
jennyf19
2026-07-20 11:41:51 -07:00
parent df4f3ebc42
commit e43d6ea666
+3 -2
View File
@@ -53,7 +53,9 @@ function deskOrientPrompt(deskName) {
// Spawn detached and resolve true only once the OS confirms the process
// started ('spawn'), false on failure ('error', e.g. the binary is missing) so
// the caller can fall back. A short timer guards the rare case neither fires.
// the caller can fall back. Node guarantees exactly one of those events fires
// for a spawn attempt, so we resolve solely from them — no timeout that could
// report an unconfirmed launch as success and skip the clipboard fallback.
function trySpawn(cmd, args, opts = {}) {
return new Promise((resolve) => {
let settled = false;
@@ -67,7 +69,6 @@ function trySpawn(cmd, args, opts = {}) {
const child = spawn(cmd, args, { detached: true, stdio: "ignore", ...opts });
child.on("error", () => done(false));
child.on("spawn", () => done(true, child));
setTimeout(() => done(true, child), 600);
} catch { resolve(false); }
});
}