Skip to content

Image upload fails ("Unable to write") when server aborts PUT request on cache hit #2467

@rbeurskens

Description

@rbeurskens

When an image is used multiple times, can can be cached by ConfyUI.
In my case, this caused Krita to show an "Unable to write" error when that happened.
This was because on the PUT request, the server returned a cache-hit json, and then closed the connection server side for me:

curl.exe -v -X PUT --data-binary "@some-image.jpg" http://<Server Host>:8188/api/etn/image/xxxxxxxx
*   Trying <Server Host>:8188...
* Connected to <Server Host> (<IP>) port 8188
* using HTTP/1.x
> PUT /api/etn/image/xxxxxxxx HTTP/1.1
> Host: <Server IP>:8188
> User-Agent: curl/8.13.0
> Accept: */*
> Content-Length: <image-length>
> Content-Type: application/x-www-form-urlencoded
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
<
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
< Content-Length: 20
< Date: Sun, 26 Apr 2026 02:48:41 GMT
< Server: Python/3.12 aiohttp/3.13.5
<
{"status": "cached"}* Send failure: Connection was aborted

I solved this by changing the code to first send a HEAD request and only send to PUT if it resulted in a not found response code.
Fixes in #2468 worked for me, so why not share it ? :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions