fix: 修复bug
This commit is contained in:
@@ -60,7 +60,15 @@ function sseSend(res, event, data) {
|
||||
}
|
||||
|
||||
function newTaskId() {
|
||||
return crypto.randomUUID();
|
||||
// `crypto.randomUUID()` exists on newer Node versions; fall back for older runtimes.
|
||||
if (crypto && typeof crypto.randomUUID === "function") return crypto.randomUUID();
|
||||
|
||||
const bytes = crypto.randomBytes(16);
|
||||
// UUID v4: set version and variant bits.
|
||||
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
||||
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
||||
const hex = bytes.toString("hex");
|
||||
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
||||
}
|
||||
|
||||
function taskDir(taskId) {
|
||||
@@ -285,12 +293,20 @@ app.post("/api/render", (req, res) => {
|
||||
|
||||
async function runSelfCheck() {
|
||||
const py = process.env.PYTHON_BIN || "python3.10";
|
||||
const checks = [
|
||||
{ name: "check_comfy", args: ["scripts/check_comfy.py"] },
|
||||
{ name: "inspect_comfy_node", args: ["scripts/inspect_comfy_node.py"] },
|
||||
];
|
||||
const selfCheckTimeoutMs = Number(process.env.SELF_CHECK_TIMEOUT_MS || 300000);
|
||||
const workflowApiPath = path.join(repoRoot, "workflow_api.json");
|
||||
const requireWorkflow = String(process.env.REQUIRE_WORKFLOW || "").trim() === "1";
|
||||
|
||||
const checks = [{ name: "check_comfy", args: ["scripts/check_comfy.py"] }];
|
||||
if (fs.existsSync(workflowApiPath) || requireWorkflow) {
|
||||
checks.push({ name: "inspect_comfy_node", args: ["scripts/inspect_comfy_node.py"] });
|
||||
} else {
|
||||
console.warn(
|
||||
`[server self-check] workflow_api.json not found at ${workflowApiPath}; skipping inspect_comfy_node (set REQUIRE_WORKFLOW=1 to enforce).`
|
||||
);
|
||||
}
|
||||
for (const c of checks) {
|
||||
const deadline = Date.now() + 90_000;
|
||||
const deadline = Date.now() + selfCheckTimeoutMs;
|
||||
let lastErr = "";
|
||||
while (Date.now() < deadline) {
|
||||
try {
|
||||
|
||||
@@ -38,6 +38,19 @@
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
<!-- Suppress noisy in-browser Babel warning (dev-only). -->
|
||||
<script>
|
||||
(function () {
|
||||
const ow = console.warn && console.warn.bind ? console.warn.bind(console) : console.warn;
|
||||
if (!ow) return;
|
||||
console.warn = function () {
|
||||
const first = arguments && arguments.length ? String(arguments[0] || "") : "";
|
||||
if (first.includes("in-browser Babel transformer")) return;
|
||||
return ow.apply(console, arguments);
|
||||
};
|
||||
})();
|
||||
</script>
|
||||
|
||||
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
|
||||
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
|
||||
<script crossorigin src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
|
||||
@@ -94,7 +107,7 @@
|
||||
showToast(m);
|
||||
});
|
||||
es.addEventListener("task", (e) => {
|
||||
try { setTaskId(JSON.parse(e.data).task_id || ""); } catch { }
|
||||
try { setTaskId(JSON.parse(e.data).task_id || ""); } catch (err) { }
|
||||
});
|
||||
es.addEventListener("done", (e) => {
|
||||
appendLog("[done] exit_code=" + e.data);
|
||||
@@ -210,7 +223,7 @@
|
||||
}
|
||||
const data = dataLines.join("\n");
|
||||
if (event === "task") {
|
||||
try { setTaskId(JSON.parse(data).task_id || ""); } catch { }
|
||||
try { setTaskId(JSON.parse(data).task_id || ""); } catch (err) { }
|
||||
} else if (event === "prog") {
|
||||
appendLog("[prog] " + data);
|
||||
} else if (event === "error") {
|
||||
|
||||
Reference in New Issue
Block a user