A successful response can be drained before delivery
MDN's bodyUsed property reports whether the body has been read; changing a reference to that object does not rewind its bytes. clone() must be called before consumption. Its two branches can also buffer unread data without a bound when their consumption speeds differ. This is a client stream-ownership issue, separate from validating HTTP status or cleaning up an abandoned transfer. It does not establish a defect in AISwapLab's content service.
What to do next
- 01
Locate the first reader
Follow the returned Response through middleware, error reporting and the actual download function. Look for convenience logging that reads the entire body, a decoder that runs before the media branch, or a reader left locked. Observe bodyUsed and the control path without dumping private content. Retain status, expected kind and the known job ID before body processing so a secondary read error does not erase useful context.
- 02
Choose one deliberate consumption path
For a small bounded JSON response, read and validate it once, then pass the reviewed parsed value to other components. For media, use a bounded staging or streaming pipeline and record approved metadata instead of reading the whole image or video for logs. If a controlled small response genuinely requires cloning, create the clone before any read and account for both consumers. Do not clone large private media into a slow or unused diagnostic branch; that can defeat the intended memory bound.
- 03
Test ownership rather than adding retries
Use a synthetic local response and a logging wrapper that consumes it first. Verify that the corrected design delivers the expected bytes or parsed object through one owner, and that failures release readers and partial files. Test the error branch as well as successful media. If the existing completed asset needs retrieval again after a local failure, refetch its authorized content route under normal validation; keep generation and download recovery separate.
A concrete example
Illustrative failure: a wrapper awaits response.text() to print a media response, then hands that same Response to code calling blob(). The second reader fails because the body was consumed. The proposed correction records safe status/type metadata and transfers the bytes once into the validated delivery path. This is a local fixture design, not an executed test or a reason to log real customer footage.
Before you call it ready
- Every Response body has a known consuming owner.
- Diagnostic code does not silently drain, clone or retain a large private body.
- The local failure remains attached to the existing completed job.
When to stop or choose another method
Stop adding another paid request or an unconditional clone when stream ownership is unclear. Fix the reader sequence and resource policy; bodyUsed is evidence of consumption, not a reset button.
