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.

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

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.

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: