Skip to content

fix(ai): pass abortSignal to reconnectToStream so stop() works after resumeStream()#14350

Open
ericallam wants to merge 1 commit intovercel:mainfrom
ericallam:fix/reconnect-stream-abort-signal
Open

fix(ai): pass abortSignal to reconnectToStream so stop() works after resumeStream()#14350
ericallam wants to merge 1 commit intovercel:mainfrom
ericallam:fix/reconnect-stream-abort-signal

Conversation

@ericallam
Copy link
Copy Markdown

Background

When a user calls resumeStream() (e.g. to reconnect to an active chat after a page refresh), the stop() method has no effect. This is because the AbortController is created after reconnectToStream() returns, so the abort signal is never connected to the resumed stream.

Summary

  • Create the AbortController before calling reconnectToStream() in makeRequest
  • Add optional abortSignal parameter to the ChatTransport.reconnectToStream interface
  • Pass the signal through in HttpChatTransport.reconnectToStream (to the fetch call)
  • Add tests verifying stop() works correctly on resumed streams

Checklist

  • Tests added (stop should abort a resumed stream — 4 test cases)
  • Patch changeset added
  • Self-reviewed

…resumeStream()

Previously, `stop()` had no effect after calling `resumeStream()` because
the AbortController was created after `reconnectToStream()` returned, and
`reconnectToStream` didn't accept an `abortSignal` parameter. This meant
the abort signal was never connected to the resumed stream.

This fix:
1. Creates the AbortController before calling `reconnectToStream()`
2. Adds `abortSignal` to the `ChatTransport.reconnectToStream` interface
3. Passes the signal through in `HttpChatTransport.reconnectToStream`
4. Adds tests verifying stop() works correctly on resumed streams
@tigent tigent bot added ai/ui anything UI related bug Something isn't working as documented labels Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/ui anything UI related bug Something isn't working as documented

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant