-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The job went missing! #12
Comments
this is my server.js import express from 'express';
import { ComfyApi, PromptBuilder, CallWrapper } from '@saintno/comfyui-sdk';
import fs from 'fs';
import { v4 as uuidv4 } from 'uuid';
const app = express();
const port = 3000;
const unique_id = uuidv4();
const api = new ComfyApi("http://localhost:8188", "unique_id");
// Load the custom workflow JSON
const workflowJson = JSON.parse(fs.readFileSync('D:/Sites/photobooth/simple.json', 'utf-8'));
app.use(express.json());
// Initialize ComfyUI API
api.on("log", (ev) => console.log(ev.detail)); // Debug logs
await api
.init(1000, 1000) // Retry settings
.waitForReady();
// POST endpoint for generating images based on promptText, positivePrompt, and optional negativePrompt
app.post('/generate', async (req, res) => {
console.log("Request received at /generate");
console.log("Request body:", req.body);
let responseSent = false;
try {
const { positivePrompt, negativePrompt } = req.body;
const promptBuilder = new PromptBuilder(
workflowJson,
["postext"],
["negtext"],
["output_image"]
)
.setInputNode("postext", "7.inputs.text")
.setInputNode("negtext", "8.inputs.text")
.setOutputNode("output_image", "11.outputs.images")
// Disable cache check
CallWrapper.prototype.handleCachedOutput = async function() { return null; };
const workflowExecution = new CallWrapper(api, promptBuilder);
workflowExecution
.onFinished((data) => {
if (!responseSent) {
responseSent = true;
console.log("Workflow finished, sending response");
res.set('Cache-Control', 'no-store');
res.json({ result: "success" });
}
})
.onFailed((err) => {
if (!responseSent) {
responseSent = true;
console.error("Workflow failed:", err);
res.status(500).json({ error: `Workflow failed: ${err.message}` });
}
})
.run();
} catch (error) {
if (!responseSent) {
responseSent = true;
console.error("Server error:", error);
res.status(500).json({ error: `Server error: ${error.message}` });
}
}
});
// Start the server
app.listen(port, () => {
console.log(`Server running on http://localhost:${port}`);
}); |
I have a pull request waiting that solves an issue where the original workflow json being used gets mutated by the inputs in memory. The other possibility might be a caching issue, does it only do it with the same inputs, including seed, or different inputs as well? Looking at your code you don't seem to be providing any inputs though, you're only defining the input and output nodes. |
yes.. i am trying to accept input parameters from postman.. i tried to take out the cache check... but still doesn't work.. it only happens when i use the same workflow, if i edit the workflow a little bit, save with the same filename, it will proceed... |
I think you just need to map the seed input and random seed each time you call the workflow! |
it works for the first time when i restart the comfyUI Server or use a new workflow json
if i use the same workflow again, it will reply : the job went missing .
The text was updated successfully, but these errors were encountered: