Skip to content

Commit

Permalink
Highlight nodes with errors in red even when workflow works fine.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed Jul 13, 2023
1 parent b2f0316 commit 876dadc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,8 @@ async def post_prompt(request):
prompt_id = str(uuid.uuid4())
outputs_to_execute = valid[2]
self.prompt_queue.put((number, prompt_id, prompt, extra_data, outputs_to_execute))
return web.json_response({"prompt_id": prompt_id, "number": number})
response = {"prompt_id": prompt_id, "number": number, "node_errors": valid[3]}
return web.json_response(response)
else:
print("invalid prompt:", valid[1])
return web.json_response({"error": valid[1], "node_errors": valid[3]}, status=400)
Expand Down
2 changes: 2 additions & 0 deletions web/scripts/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ class ComfyApi extends EventTarget {
response: await res.json(),
};
}

return await res.json();
}

/**
Expand Down
16 changes: 10 additions & 6 deletions web/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ export class ComfyApp {
LGraphCanvas.prototype.drawNodeShape = function (node, ctx, size, fgcolor, bgcolor, selected, mouse_over) {
const res = origDrawNodeShape.apply(this, arguments);

const nodeErrors = self.lastPromptError?.node_errors[node.id];
const nodeErrors = self.lastNodeErrors?.[node.id];

let color = null;
let lineWidth = 1;
Expand All @@ -845,7 +845,7 @@ export class ComfyApp {
} else if (self.dragOverNode && node.id === self.dragOverNode.id) {
color = "dodgerblue";
}
else if (self.lastPromptError != null && nodeErrors?.errors) {
else if (nodeErrors?.errors) {
color = "red";
lineWidth = 2;
}
Expand Down Expand Up @@ -1413,7 +1413,7 @@ export class ComfyApp {
}

this.#processingQueue = true;
this.lastPromptError = null;
this.lastNodeErrors = null;

try {
while (this.#queueItems.length) {
Expand All @@ -1423,12 +1423,16 @@ export class ComfyApp {
const p = await this.graphToPrompt();

try {
await api.queuePrompt(number, p);
const res = await api.queuePrompt(number, p);
this.lastNodeErrors = res.node_errors;
if (this.lastNodeErrors.length > 0) {
this.canvas.draw(true, true);
}
} catch (error) {
const formattedError = this.#formatPromptError(error)
this.ui.dialog.show(formattedError);
if (error.response) {
this.lastPromptError = error.response;
this.lastNodeErrors = error.response.node_errors;
this.canvas.draw(true, true);
}
break;
Expand Down Expand Up @@ -1534,7 +1538,7 @@ export class ComfyApp {
clean() {
this.nodeOutputs = {};
this.nodePreviewImages = {}
this.lastPromptError = null;
this.lastNodeErrors = null;
this.lastExecutionError = null;
this.runningNodeId = null;
}
Expand Down

0 comments on commit 876dadc

Please sign in to comment.