Describe the bug
Issue Summary
I am using useChat
from 'ai/react'
with OpenAI’s GPT-4o model. In the production version of my app, I am intermittently receiving incomplete responses, but onFinished
is still being triggered as if the response were complete.
This issue does not occur in the development version, only in production.
Environment Details
- Library:
ai/react
- Model:
gpt-4o
- Deployment: Hosted on Cloudflare
- Issue Occurrence: Only in production, works fine in development
Additional Context
- This does not happen in development mode.
- My site is hosted on Cloudflare, which might introduce caching or network-related behaviors.
- No network errors are reported in the console or logs.
Would appreciate any insights or fixes regarding this issue! Let me know if additional logs or debugging information is required. Thanks!
Link to the Bolt URL that caused the error
Steps to Reproduce
- Use
useChat
fromai/react
to send a request to OpenAI’s GPT-4o. - Deploy the application to production (hosted on Cloudflare).
- Observe that in some cases, the response is cut off or incomplete, yet
onFinished
still fires.
Expected Behavior
- The full response should be received before
onFinished
is triggered. - If the response is incomplete,
onFinished
should not fire prematurely.
Screen Recording / Screenshot
No response
Platform
- OS: Linux
- Browser: Chrome
- Version: 132.0.6834.110
Provider Used
OpenAI
Model Used
GPT-4o model