Skip to content

Guard image2image abort errors after client disconnect #277

Description

@coderabbitai

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions