You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Vercel AI: ai 6 with a v2 provider crashes with 'Maximum call stack size exceeded' #26905
With ai@6 and an older provider package (@ai-sdk/openai@2, @ai-sdk/google@2, ...), every generateText and streamText call fails with RangeError: Maximum call stack size exceeded when Sentry is loaded. Without Sentry, the same call works.
Affected: ai@6 with a v2 provider, on @sentry/node 10.64.0 and later. ai@6 with v3 providers (@ai-sdk/openai@3, ...) works, and so do ai 4, 5 and 7.
Cause
ai 6 wraps older models in a Proxy before calling them. Our instrumentation then assigns its own doGenerate/doStream onto that proxy. The proxy passes the assignment through to the model underneath, so our wrapper and ai's wrapper end up calling each other until the stack overflows.
Our tests didn't catch it because they only use MockLanguageModelV3, which ai doesn't wrap.
$ node --import ./instrument.mjs app.mjs
FAILED: RangeError Maximum call stack size exceeded
$ node app.mjs
OK: hi
A hand-written { specificationVersion: 'v2', doGenerate, ... } model fails the same way.
Fix direction
Don't assign onto the resolved model. For example, return a wrapping object or proxy from the resolveLanguageModel hook, or patch the unwrapped target. A regression test should use a spec-v2 model on ai 6.
Activity
linear-code commentedon Nov 25, 2026
JS-4164