useChat not working with SWR 2.3.2
Description
Since updating SWR to its last version (2.3.2), i get the following error:
It works perfectly with 2.3.1 and 2.3.0
Versions:
"@ai-sdk/openai": "1.1.9",
"ai": "4.1.34",
"swr": "2.3.2",
PS: it's not the first time I get this issue with a swr version, previously I had to use a beta version to get it work until swr 2.3.0 was available => https://github.com/vercel/ai/issues/2769
Code example
No response
AI provider
No response
Additional context
No response
Hey @defless! Are you still experiencing this issue? If so, which version of @ai-sdk/react are you on?
with ai sdk 5 swr has been removed from useChat
Identify issue type
Identified as Bug
Confidence: High
Rationale
This is a concrete runtime failure of the existing useChat hook caused by an SWR dependency update, so it is a bug rather than a request for new functionality.
Evidence
useChatthrows a React console error about an uncached promise after upgrading SWR from 2.3.1 to 2.3.2.- The reporter states the same code works with SWR 2.3.0 and 2.3.1, indicating a version-specific regression.
- A maintainer notes that AI SDK 5 removes SWR from
useChat, but does not dispute the reported failure in AI SDK 4.1.34.