comfyui-mcp 0.50.12 → 0.50.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -444,11 +444,31 @@ function portKillHint(port) {
|
|
|
444
444
|
? `To free the port manually:\n PowerShell: ${ps}\n bash/zsh: ${sh}`
|
|
445
445
|
: `To free the port manually:\n bash/zsh: ${sh}\n PowerShell: ${ps}`;
|
|
446
446
|
}
|
|
447
|
+
/**
|
|
448
|
+
* PROBE TIMEOUT. These four inspections run SYNCHRONOUSLY, so a command that
|
|
449
|
+
* hangs blocks the whole event loop — no bridge traffic, no agent turns,
|
|
450
|
+
* nothing — and they run on the startup/takeover path where being stuck is
|
|
451
|
+
* indistinguishable from being broken. `lsof` is the known offender (it stalls
|
|
452
|
+
* on unreachable network mounts), and `netstat` is slow on a busy host.
|
|
453
|
+
*
|
|
454
|
+
* 5s matches what the rest of the codebase already uses for these EXACT
|
|
455
|
+
* commands — port-owner.ts times out its `lsof`/`netstat` and process-control.ts
|
|
456
|
+
* its `tasklist`. These copies simply never got it.
|
|
457
|
+
*
|
|
458
|
+
* Timing out costs nothing in correctness: both callers already fail closed on
|
|
459
|
+
* a throw (null / "unknown"), and both READ that as "could not determine" —
|
|
460
|
+
* pidListeningOnPort's null makes the caller decline to claim a takeover rather
|
|
461
|
+
* than assert the port is free.
|
|
462
|
+
*/
|
|
463
|
+
const PORT_PROBE_TIMEOUT_MS = 5000;
|
|
447
464
|
/** Resolve which pid is LISTENING on a local TCP port (null if none/unknown). */
|
|
448
465
|
function pidListeningOnPort(port) {
|
|
449
466
|
try {
|
|
450
467
|
if (process.platform === "win32") {
|
|
451
|
-
const out = execFileSync("netstat", ["-ano", "-p", "tcp"], {
|
|
468
|
+
const out = execFileSync("netstat", ["-ano", "-p", "tcp"], {
|
|
469
|
+
encoding: "utf8",
|
|
470
|
+
timeout: PORT_PROBE_TIMEOUT_MS,
|
|
471
|
+
});
|
|
452
472
|
for (const line of out.split(/\r?\n/)) {
|
|
453
473
|
const m = line.match(/TCP\s+\S+:(\d+)\s+\S+\s+LISTENING\s+(\d+)\s*$/i);
|
|
454
474
|
if (m && Number(m[1]) === port)
|
|
@@ -458,6 +478,7 @@ function pidListeningOnPort(port) {
|
|
|
458
478
|
}
|
|
459
479
|
const out = execFileSync("lsof", ["-ti", `tcp:${port}`, "-s", "tcp:LISTEN"], {
|
|
460
480
|
encoding: "utf8",
|
|
481
|
+
timeout: PORT_PROBE_TIMEOUT_MS,
|
|
461
482
|
});
|
|
462
483
|
const pid = Number(out.trim().split(/\s+/)[0]);
|
|
463
484
|
return Number.isInteger(pid) && pid > 0 ? pid : null;
|
|
@@ -472,10 +493,14 @@ function processNameOf(pid) {
|
|
|
472
493
|
if (process.platform === "win32") {
|
|
473
494
|
const out = execFileSync("tasklist", ["/FI", `PID eq ${pid}`, "/FO", "CSV", "/NH"], {
|
|
474
495
|
encoding: "utf8",
|
|
496
|
+
timeout: PORT_PROBE_TIMEOUT_MS,
|
|
475
497
|
});
|
|
476
498
|
return /^"([^"]+)"/m.exec(out)?.[1] ?? "unknown";
|
|
477
499
|
}
|
|
478
|
-
return (execFileSync("ps", ["-p", String(pid), "-o", "comm="], {
|
|
500
|
+
return (execFileSync("ps", ["-p", String(pid), "-o", "comm="], {
|
|
501
|
+
encoding: "utf8",
|
|
502
|
+
timeout: PORT_PROBE_TIMEOUT_MS,
|
|
503
|
+
}).trim() ||
|
|
479
504
|
"unknown");
|
|
480
505
|
}
|
|
481
506
|
catch {
|