Skip to content

fix: prevent Chat resume-stream onFinish errors when requests overlap#16620

Merged
aayush-kapoor merged 2 commits into
mainfrom
bugfix/15668-1
Jul 14, 2026
Merged

fix: prevent Chat resume-stream onFinish errors when requests overlap#16620
aayush-kapoor merged 2 commits into
mainfrom
bugfix/15668-1

Conversation

@lgrammel

@lgrammel lgrammel commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Background

Overlapping chat requests could clear the shared active response before a resume-stream request reached its finally block, causing onFinish handling to log a TypeError in development.

Summary

Chat.makeRequest now keeps a request-local active response for finish handling and only clears the shared activeResponse when it still belongs to the finishing request.

Testing

Kept the focused regression test covering an overlapped resumeStream and sendMessage request where activeResponse is cleared before the resume stream finishes.

Related Issues

Fixes #15668

Co-authored-by: alexanderjacobsen [email protected]

@aayush-kapoor aayush-kapoor added the backport Admins only: add this label to a pull request in order to backport it to the prior version label Jul 14, 2026
@aayush-kapoor
aayush-kapoor merged commit 0bc8d4f into main Jul 14, 2026
58 checks passed
@aayush-kapoor
aayush-kapoor deleted the bugfix/15668-1 branch July 14, 2026 21:21
github-actions Bot added a commit that referenced this pull request Jul 14, 2026
…#16620)

## Background

Overlapping chat requests could clear the shared active response before
a resume-stream request reached its finally block, causing onFinish
handling to log a TypeError in development.

## Summary

Chat.makeRequest now keeps a request-local active response for finish
handling and only clears the shared activeResponse when it still belongs
to the finishing request.

## Testing

Kept the focused regression test covering an overlapped resumeStream and
sendMessage request where activeResponse is cleared before the resume
stream finishes.

## Related Issues

Fixes #15668

Co-authored-by: alexanderjacobsen
<[email protected]>
@github-actions github-actions Bot removed the backport Admins only: add this label to a pull request in order to backport it to the prior version label Jul 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ Backport PR created: #17258

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Published in:

Package Version
ai 7.0.28 github npm
@ai-sdk/amazon-bedrock 5.0.22 github npm
@ai-sdk/angular 3.0.28 github npm
@ai-sdk/azure 4.0.15 github npm
@ai-sdk/deepseek 3.0.11 github npm
@ai-sdk/google 4.0.16 github npm
@ai-sdk/google-vertex 5.0.20 github npm
@ai-sdk/harness 1.0.33 github npm
@ai-sdk/harness-claude-code 1.0.34 github npm
@ai-sdk/harness-codex 1.0.35 github npm
@ai-sdk/harness-deepagents 1.0.32 github npm
@ai-sdk/harness-opencode 1.0.34 github npm
@ai-sdk/harness-pi 1.0.33 github npm
@ai-sdk/langchain 3.0.28 github npm
@ai-sdk/llamaindex 3.0.28 github npm
@ai-sdk/otel 1.0.28 github npm
@ai-sdk/policy-opa 1.0.28 github npm
@ai-sdk/react 4.0.30 github npm
@ai-sdk/rsc 3.0.28 github npm
@ai-sdk/sandbox-just-bash 1.0.33 github npm
@ai-sdk/sandbox-vercel 1.0.33 github npm
@ai-sdk/svelte 5.0.28 github npm
@ai-sdk/tui 1.0.28 github npm
@ai-sdk/vue 4.0.28 github npm
@ai-sdk/workflow 1.0.28 github npm
@ai-sdk/workflow-harness 1.0.33 github npm

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chat.makeRequest finally throws on this.activeResponse!.state when activeResponse is undefined (should be ?.)

2 participants