AI SDK type instantiation possibly infinite
Hey there. I'm running tanstack start and the AI sdk. The issue I'm getting is
Type instantiation is excessively deep and possibly infinite.. I'm getting this when attempting to return a UIMessage nor ModelMessage from a server function created by createServerFn.
Could someone please help me to get this to work? Chat message persistence doesn't work without this
https://tsplay.dev/Wk6kLmTS Playground - An online editor for exploring TypeScript and JavaS...
The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.
3 Replies
genetic-orange•3mo ago
this is an ai sdk issue
maybe upgrade zod
genetic-orange•3mo ago
GitHub
Type instantiation is excessively deep and possibly infinite. · Is...
Description Using: zod: "^3.25.76" @ai-sdk/openai: "^2.0.0-beta.5", ai: "^5.0.0-beta.11", I get the above typescript error when defining a tool. I use the example ai-c...
robust-apricotOP•3mo ago
This is running the latest of both. I'm not sure if this is an ai sdk issue as zod doesn't need to be involved here at all. i uninstalled it and it's doing the same even without zod existing in the TS playground - see https://tsplay.dev/Wyr6gw
same on local when uninstalling zod completely. the code isn't even running the ai sdk, just returning an empty object asserted as a type - which is why i think it's an internal tanstack issue
Going deeper into the issue, it's to do with the
SharedV2ProviderOptions - the type is Record<string, Record<string, JSONValue>>