fix: 为 callPython 添加 spawn 错误处理,防止进程启动失败时永久挂起

This commit is contained in:
MikiVL 2026-05-05 13:36:44 +08:00
parent aee1c6bb69
commit 1c164ea3d9

View File

@ -28,6 +28,7 @@ function callPython(payload) {
reject(new Error("Python 返回了无效 JSON: " + stdout)); reject(new Error("Python 返回了无效 JSON: " + stdout));
} }
}); });
proc.on("error", (e) => reject(new Error("Python 进程启动失败: " + e.message)));
proc.stdin.write(JSON.stringify(payload) + "\n"); proc.stdin.write(JSON.stringify(payload) + "\n");
proc.stdin.end(); proc.stdin.end();
}); });