I’m having trouble with my n8n workflow on Docker. It used to work fine but now it’s acting up. The workflow gets an image from a web form and saves it on the server. But now it just hangs and gives a 500 error.
When I check the n8n dashboard, the execution is stuck on “running…” forever. The file shows up in the right folder, but it’s messed up and won’t open as an image.
The logs say there’s a problem moving the file from the temp folder to the final spot. I’ve tried asking ChatGPT for help, but I’m still stuck.
Any ideas on how to fix this? I’m worried about starting from scratch because I’ve made a bunch of custom changes. How can I figure out what’s going wrong?
Here’s a simple example of what my workflow looks like:
const getImage = async (url) => {
const response = await fetch(url);
return response.blob();
};
const saveImage = async (imageData, filename) => {
await fs.writeFile(`/images/${filename}`, imageData);
};
const processUpload = async (webhookData) => {
const imageUrl = webhookData.imageUrl;
const filename = webhookData.filename;
const imageData = await getImage(imageUrl);
await saveImage(imageData, filename);
return { success: true };
};
Any help would be awesome!
hey emma, sucks ur having trouble. i had a similar issue n what fixed it for me was clearing the docker cache. try running ‘docker system prune’ (carefull tho, it’ll delete unused stuff). also, check ur logs for any weird errors bout file permissions or disk space. those can mess things up too. good luck!
I’ve had a similar issue with n8n workflows getting stuck, and it turned out to be a permissions problem. Since you’re using Docker, check if the container has the right permissions to write to the destination folder. You might need to adjust the user/group settings or mount volumes differently.
Another thing to look at is disk space. If your Docker host is running low on space, it can cause weird file corruption issues. I’d suggest running ‘docker system df’ to check your disk usage.
Have you tried running the workflow with debug logging enabled? That often reveals issues that aren’t obvious in normal logs. You can set the LOG_LEVEL environment variable to ‘debug’ when starting your n8n container.
Lastly, it might be worth checking if there’s any network issues between your n8n instance and the source of the images. Intermittent connectivity problems can lead to partial downloads and corrupt files.
Hope this helps point you in the right direction!
I encountered a similar issue with n8n workflows and image processing. One thing that helped me was implementing a retry mechanism for the file operations. Sometimes network hiccups or temporary I/O issues can cause these problems.
Consider wrapping your file operations in a try-catch block with a few retries. Also, ensure you’re properly closing file handles after writing. Here’s a quick example:
const saveImage = async (imageData, filename, retries = 3) => {
for (let i = 0; i < retries; i++) {
try {
await fs.writeFile(`/images/${filename}`, imageData);
return;
} catch (error) {
console.error(`Attempt ${i + 1} failed: ${error.message}`);
await new Promise(resolve => setTimeout(resolve, 1000));
}
}
throw new Error('Failed to save image after multiple attempts');
};
This approach has resolved similar issues for me in the past. Good luck troubleshooting!