n8n automation freezes and creates damaged files

I’m running n8n in a Docker container on my local machine. I have a basic automation that receives data through a webhook and saves it as a file using the file writer node. The file gets saved to a folder that’s shared between the container and my host system.

This workflow was working fine until I modified the Docker container by adding an image processing library. Now when the webhook gets triggered, the execution gets stuck forever and shows a 500 error. In the n8n interface, I can see the execution stays in “running” status and never completes.

The strange part is that a file does get created in the target folder with the right size, but it’s corrupted and can’t be opened as an image. The logs show an error about moving files from the temp directory to the final location, but the file is actually there.

Here’s my workflow setup:

{
  "name": "photo-upload-handler",
  "nodes": [
    {
      "parameters": {},
      "name": "Trigger",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [250, 300],
      "id": "start-node-123"
    },
    {
      "parameters": {
        "filePath": "=/uploads/gallery/{{ $json.query.imagename }}.png",
        "binaryPropertyName": "=filedata",
        "options": {}
      },
      "name": "Save File",
      "type": "n8n-nodes-base.writeBinaryFile",
      "typeVersion": 1,
      "position": [800, 300],
      "id": "file-writer-456"
    },
    {
      "parameters": {
        "authentication": "headerAuth",
        "httpMethod": "POST",
        "path": "image-upload-endpoint",
        "responseMode": "lastNode",
        "options": {}
      },
      "name": "HTTP Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [500, 300],
      "webhookId": "webhook-789",
      "id": "http-receiver-abc"
    }
  ],
  "connections": {
    "HTTP Trigger": {
      "main": [
        [
          {
            "node": "Save File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true
}

I’m getting this error in the logs about file operations failing, but I can see the files are actually being created. Has anyone seen this before? I don’t want to rebuild everything from scratch since I’ve made lots of custom changes.

Had the same issue after tweaking my Docker setup. The new image processing library is probably messing with file permissions or creating competing processes that interrupt file writes. That’s why your files show the right size but won’t open - the write gets cut off halfway through. Check your Docker volume mount permissions and make sure the library isn’t creating conflicting temp directories. Try running the container with --user flag matching your host user ID, or temporarily disable the image processing library to see if that fixes it. You might also need to adjust the file writer node’s temp directory if the library changed the default paths.

sounds like a race condition with ur new library and n8n’s file handling. try bumping up the execution timeout in n8n settings, and see if the library hooks into file system events. also, check docker logs - library errors might not show up in n8n interface. corrupted files mean something interrupted the write process.

This is a filesystem locking issue between n8n and your image processing library. The library’s probably holding file handles or creating temp files in the same directory where n8n’s trying to write. Files show up with the right size but corrupted content because the write gets interrupted halfway through. Change your temp directory path in Docker so n8n and the library don’t step on each other. Add a separate volume mount for temp files and set N8N_DEFAULT_BINARY_DATA_MODE to ‘filesystem’ with its own temp path. Also check if your image library has cleanup processes that might mess with n8n’s file operations.