diffusers: generation continues after client disconnect and blocks the event loop — no cancellation
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 52/100
Rechercherichtung
Beginne in python/diffusers_server/server.py am create_image-Endpunkt und seinem synchronen generate_images-Aufruf. Vergleiche das Verhalten bei der Abbruchbehandlung des Request-Kontexts im llama.cpp-Chatpfad und reproduziere eine Client-Trennung während des Modellladens oder der Generierung. Die Aufgabe ist erledigt, wenn abgebrochene Arbeiten beendet werden oder ausdrücklich als nicht abbrechbar dokumentiert sind, ohne nachfolgende Anfragen dahinter zu blockieren.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Description
The diffusers backend does not cancel image generation when the requesting client disconnects. A request whose client has timed out or closed the connection still runs to completion — model load included — and the response is written to a socket nobody reads. Subsequent requests queue behind these abandoned jobs, so client-side retries (the natural reaction to a timeout) compound the problem instead of recovering from it.
Likely mechanism (from source)
In python/diffusers_server/server.py, create_image is an async def endpoint that calls the synchronous generate_images pipeline directly — no thread executor, no request.is_disconnected() check, no cancellation path. The blocking call occupies the event loop for the full generation, so the server cannot observe the disconnect even in principle, and every other request serializes behind it.
Environment
- Docker Model Runner v1.2.6 (Docker Desktop), macOS, Apple Silicon (M1 Pro, 16 GB). The handler is unchanged on current
mainand in v1.2.7/v1.2.8 release notes. - Model:
stable-diffusion(DDUF, diffusers backend, MPS float16)
Steps to reproduce
- Ensure the diffusers runner is not resident (cold start), so the first request also pays the model load.
POST /engines/diffusers/v1/images/generationswith a client timeout shorter than load + generation (e.g. 120 s while the DDUF load alone takes 2+ min on a memory-pressured host).- Let the client time out and close the connection. Send a second request from another client.
Observed
- The first request's generation starts after its client is gone and runs to completion; the engine logs
200 OKto the disconnected socket. In one instance the host slept mid-queue and the engine completed the abandoned job ~6 hours after the client vanished, immediately on wake. - The second request waits behind the abandoned job and can itself time out having never started.
- The abandoned work holds the model's residency (~7 GB for stable-diffusion) and the GPU for its full duration.
Expected
Client disconnect (or at minimum, connection close before generation starts) cancels the pending/running job — the behavior the llama.cpp chat path already exhibits via request context cancellation. Alternatively: a documented statement that diffusers jobs are uncancellable once accepted, so clients can choose long timeouts over retries.
Impact
Any client that enforces a per-request timeout (agent tool loops, gateways, proxies) turns one slow cold start into a pile-up: each timeout triggers a retry that queues behind a job whose consumer no longer exists.
- Vorherrschende Sprache
- Go
- Sterne
- 665
- Forks
- 161
- Ø Merge
- 4 Std. 25 Min.
- Gemergte PRs (30 T.)
- 18
Entwicklungsumgebung
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Kein Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus docker/model-runner
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
docker/model-runner#1118 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 20/100
docker/model-runner#1107 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 43/100
docker/model-runner#1103 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 Ein halber Tag Anfängerfreundlichkeit 45/100
docker/model-runner#1100 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
docker/model-runner#1077 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in docker/model-runner
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
limitlessprojects/Go-Hybrid#4764 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[bug]: lint fails on main, generated CLI docs out of dateEvtl. vergeben @bupd hat das heute übernommen. Offenbug documentation
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
goharbor/harbor-cli#1180 ·
Maintainer antworten meist innerhalb von 1 Tag
-
crane: mutate --env adds duplicate PATH on Windows images when key case differsEvtl. vergeben @aad1tyaaaaa hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
google/go-containerregistry#2523 ·
Maintainer antworten meist innerhalb von 4 Tagen
-
bosh_io_stemcell_type: regular does not work for noble and resolute as it adds -go_agent as suffixOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
cloudfoundry/bosh-deployment-resource#138 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100