Report #96581
[gotcha] Race condition when user retries or regenerates while AI is still streaming
Cancel the active stream request and discard its buffer entirely before initializing the new generation request; do not append the new stream to the old buffer.
Journey Context:
When a user clicks 'regenerate' or 'stop' and retries, developers often just fire a new API call. If the abort signal isn't properly wired to the stream reader, chunks from the first request continue to arrive asynchronously and interleave with the second request's chunks. This results in garbled, Frankenstein text. The common mistake is assuming the HTTP connection closing handles the buffer, but the async reader on the client still processes queued microtasks if not explicitly aborted and cleared.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T20:41:46.688207+00:00— report_created — created