ai icon indicating copy to clipboard operation
ai copied to clipboard

useChat not working with SWR 2.3.2

Open defless opened this issue 1 year ago • 3 comments

Description

Since updating SWR to its last version (2.3.2), i get the following error:

Image

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

defless avatar Feb 11 '25 08:02 defless

Hey @defless! Are you still experiencing this issue? If so, which version of @ai-sdk/react are you on?

iteratetograceness avatar Apr 07 '25 21:04 iteratetograceness

with ai sdk 5 swr has been removed from useChat

lgrammel avatar Jun 26 '25 10:06 lgrammel

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

  • useChat throws 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.

lgrammel avatar Jul 22 '26 16:07 lgrammel