Summary
Add client-abort guards to the /v1/images/image2image error paths in src/proxy.ts.
Rationale
The handler now passes clientAbort.signal to source and mask URL downloads and to the upstream payFetch request. When the client disconnects, either operation can reject with an abort error.
The parse catch currently treats an aborted URL download as invalid input and can try to write a 400 response. The outer catch can log the abort and try to write a 502 response. The closed response must not receive either error response.
Required changes
- In the parse catch that resolves
image and mask input URLs, return immediately when clientAbort.signal.aborted.
- In the outer catch around the upstream image2image request, return immediately when
clientAbort.signal.aborted.
- Preserve the current
400 and 502 behavior for non-abort errors.
- Add Vitest coverage for client disconnect during:
- source or mask URL download
- upstream
payFetch
Acceptance criteria
- A client disconnect during either path does not log an image-editing error.
- A client disconnect during either path does not call
res.writeHead() or res.end() to send an error response.
- Non-abort failures retain their current error responses.
Backlinks
Summary
Add client-abort guards to the
/v1/images/image2imageerror paths insrc/proxy.ts.Rationale
The handler now passes
clientAbort.signalto source and mask URL downloads and to the upstreampayFetchrequest. When the client disconnects, either operation can reject with an abort error.The parse catch currently treats an aborted URL download as invalid input and can try to write a
400response. The outer catch can log the abort and try to write a502response. The closed response must not receive either error response.Required changes
imageandmaskinput URLs, return immediately whenclientAbort.signal.aborted.clientAbort.signal.aborted.400and502behavior for non-abort errors.payFetchAcceptance criteria
res.writeHead()orres.end()to send an error response.Backlinks