My project works locally but fails to run on Vercel

I can’t quite understand this error and it only appears when invoking a serverless function (Astro) on Vercel. It seems to have something to do with the AI SDK, but it’s quite strange because my function fails in prod but works locally.

I’m on Node v20 both locally and on Vercel; AI SDK@^4.0.20.

2 Likes

For added context—this is a serverless vercel function. The build passes, but this invokes with a 500 immediately.

2 Likes

Fixed it.

The fix process:

  • npm why module-in-the-middle
  • look where it’s used
  • @otel and @sentry/otel

Turns out Sentry auto-instrumented generateObject and made it crash. 🤯 Wild that they didn’t show up in the stack trace at all but ai did.

Removing Sentry fixed it.

3 Likes

Hey, Tejas! Nice to see you here. Glad you got a solution - thanks for sharing. We also shared it with the team internally for info :pray:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.