Skip to content

Commit

Permalink
Handle invalid ComfyUI prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
mschuettlerTNG committed Nov 22, 2024
1 parent 0bfdc8f commit 83f6b9e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion WebUI/src/assets/js/store/comfyUi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineStore } from "pinia";
import { WebSocket } from "partysocket";
import { ComfyUIApiWorkflow, Setting, useImageGeneration } from "./imageGeneration";
import { useI18N } from "./i18n";
import { toast } from "../toast";

const WEBSOCKET_OPEN = 1;

Expand Down Expand Up @@ -141,7 +142,7 @@ export const useComfyUi = defineStore("comfyUi", () => {
modifySettingInWorkflow(mutableWorkflow, 'negativePrompt', imageGeneration.negativePrompt);
modifySettingInWorkflow(mutableWorkflow, 'batchSize', imageGeneration.batchSize);

fetch(`http://${comfyHostAndPort.value}/prompt`, {
const result = await fetch(`http://${comfyHostAndPort.value}/prompt`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
Expand All @@ -151,8 +152,14 @@ export const useComfyUi = defineStore("comfyUi", () => {
client_id: clientId
})
})
if (result.status > 299) {
throw new Error(`ComfyUI Backend responded with ${result.status}: ${await result.text()}`)
}
} catch (ex) {
console.error('Error generating image', ex);
toast.error('Backend could not generate image.');
imageGeneration.processing = false;
imageGeneration.currentState = "no_start"
} finally {
}
}
Expand Down

0 comments on commit 83f6b9e

Please sign in to comment.