From 62df715655a3c9f1d9095a334845a980942ebf46 Mon Sep 17 00:00:00 2001 From: bennykok Date: Fri, 7 Jun 2024 12:57:06 -0700 Subject: [PATCH] fix: prompt error --- custom_routes.py | 10 ++++++---- web-plugin/index.js | 29 +++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/custom_routes.py b/custom_routes.py index 3dc1abd..c1839a5 100644 --- a/custom_routes.py +++ b/custom_routes.py @@ -25,8 +25,10 @@ import struct from logging import basicConfig, getLogger import logfire -if os.environ.get('LOGFIRE_TOKEN', None) is not None: - logfire.configure() +# if os.environ.get('LOGFIRE_TOKEN', None) is not None: +logfire.configure( + send_to_logfire="if-token-present" +) # basicConfig(handlers=[logfire.LogfireLoggingHandler()]) logfire_handler = logfire.LogfireLoggingHandler() logger = getLogger("comfy-deploy") @@ -323,7 +325,7 @@ async def stream_prompt(data): # When there are critical errors, the prompt is actually not run await update_run(prompt_id, Status.FAILED) # return web.Response(status=500, reason=f"{error_type}: {e}, {stack_trace_short}") - raise Exception("Prompt failed") + # raise Exception("Prompt failed") status = 200 @@ -339,7 +341,7 @@ async def stream_prompt(data): # When there are critical errors, the prompt is actually not run if "error" in res: await update_run(prompt_id, Status.FAILED) - raise Exception("Prompt failed") + # raise Exception("Prompt failed") return res # return web.json_response(res, status=status) diff --git a/web-plugin/index.js b/web-plugin/index.js index 009201e..67a9e29 100644 --- a/web-plugin/index.js +++ b/web-plugin/index.js @@ -15,7 +15,32 @@ function sendEventToCD(event, data) { function dispatchAPIEventData(data) { const msg = JSON.parse(data); + + // Custom parse error + if (msg.error) { + let message = msg.error.message; + if (msg.error.details) + message += ": " + msg.error.details; + for (const [nodeID, nodeError] of Object.entries( + msg.node_errors, + )) { + message += "\n" + nodeError.class_type + ":"; + for (const errorReason of nodeError.errors) { + message += + "\n - " + errorReason.message + ": " + errorReason.details; + } + } + + app.ui.dialog.show(message); + if (error.response) { + app.lastNodeErrors = msg.node_errors; + app.canvas.draw(true, true); + } + } + switch (msg.event) { + case "error": + break; case "status": if (msg.data.sid) { // this.clientId = msg.data.sid; @@ -52,8 +77,8 @@ function dispatchAPIEventData(data) { break; default: api.dispatchEvent(new CustomEvent(msg.type, { detail: msg.data })); - // default: - // if (this.#registered.has(msg.type)) { + // default: + // if (this.#registered.has(msg.type)) { // } else { // throw new Error(`Unknown message type ${msg.type}`); // }