sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Vercel integration is causing runtime errors in undici integration

Open bryanrsmith opened this issue 2 years ago • 9 comments

Is there an existing issue for this?

  • [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
  • [X] I have reviewed the documentation https://docs.sentry.io/
  • [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

^7.101.1

Framework Version

No response

Link to Sentry event

No response

SDK Setup

No response

Steps to Reproduce

Sometime between the evening of May 23 and morning of May 24 all of my Vercel projects that use @sentry/node have started producing runtime errors when using native fetch (undici). I have made no relevant code changes in that time frame (deployments are being triggered by webhooks from my CMS). Projects build successfully as normal, but my pre-deployment tests fail, preventing Vercel from aliasing the new deployments to production. All serverless functions that make fetch calls appear to be crashing with the following error:

TypeError: request.headers.split is not a function
at setHeadersOnRequest (/var/task/node_modules/@sentry/node/cjs/integrations/undici/index.js:266:39)
at _onRequestCreate (/var/task/node_modules/@sentry/node/cjs/integrations/undici/index.js:177:7)
at Channel.publish (node:diagnostics_channel:143:9)
at new Request (node:internal/deps/undici/undici:6295:27)
at Client.[dispatch] (node:internal/deps/undici/undici:9077:25)
at Intercept (node:internal/deps/undici/undici:8812:20)
at Client.[Intercepted Dispatch] (node:internal/deps/undici/undici:5673:16)
at Client.dispatch (node:internal/deps/undici/undici:5689:44)
at Pool.[dispatch] (node:internal/deps/undici/undici:5920:32)
at Pool.[Intercepted Dispatch] (node:internal/deps/undici/undici:5666:33)
Node.js process exited with exit status: 129. The logs above can help with debugging the issue.

Disabling Sentry by commenting out the Sentry.init() call has allowed me to resume deploying my projects.

Expected Result

Sentry instrumentation shouldn't break the app :-)

Actual Result

All node.js serverless functions crash with the following error:

TypeError: request.headers.split is not a function at setHeadersOnRequest (/var/task/node_modules/@sentry/node/cjs/integrations/undici/index.js:266:39) at _onRequestCreate (/var/task/node_modules/@sentry/node/cjs/integrations/undici/index.js:177:7) at Channel.publish (node:diagnostics_channel:143:9) at new Request (node:internal/deps/undici/undici:6295:27) at Client.[dispatch] (node:internal/deps/undici/undici:9077:25) at Intercept (node:internal/deps/undici/undici:8812:20) at Client.[Intercepted Dispatch] (node:internal/deps/undici/undici:5673:16) at Client.dispatch (node:internal/deps/undici/undici:5689:44) at Pool.[dispatch] (node:internal/deps/undici/undici:5920:32) at Pool.[Intercepted Dispatch] (node:internal/deps/undici/undici:5666:33) Node.js process exited with exit status: 129. The logs above can help with debugging the issue.

bryanrsmith avatar May 24 '24 17:05 bryanrsmith

having the same issue with serverless functions in our production vercel deployments. posted timeline matches with timeline in which our issues began - sometime between night of May 23 and morning of May 24

trevcarr95 avatar May 24 '24 18:05 trevcarr95

https://github.com/getsentry/sentry-javascript/issues/10936

This was an bug in Node.js itself with Undici unfortunately - they released a breaking change in a minor. This was fixed with 7.106.0: https://github.com/getsentry/sentry-javascript/releases/tag/7.106.0. Please upgrade your SDK! Thanks :)

AbhiPrasad avatar May 24 '24 18:05 AbhiPrasad

This is also already fixed on Sentry 8.x for those who are using the new major version.

AbhiPrasad avatar May 24 '24 18:05 AbhiPrasad

Got it. Vercel's runtime must have updated last night, exposing us to this issue. Will update the SDK. Thanks!

bryanrsmith avatar May 24 '24 19:05 bryanrsmith

Vercel loves making fundamental changes on Friday. This is not the first time.

pdparchitect avatar May 25 '24 10:05 pdparchitect

I use @sentry/nextjs and i get this error as well. Installing the latest version of @sentry/nextjs doesnt fix it. Uncaught Exception: TypeError: request.headers.split is not a function at setHeadersOnRequest (/var/task/node_modules/@sentry/nextjs/node_modules/@sentry/node/cjs/integrations/undici/index.js:247:39) at _onRequestCreate (/var/task/node_modules/@sentry/nextjs/node_modules/@sentry/node/cjs/integrations/undici/index.js:151:9) at Channel.publish (node:diagnostics_channel:143:9) at new Request (node:internal/deps/undici/undici:6295:27) at [dispatch] (node:internal/deps/undici/undici:9077:25) at Intercept (node:internal/deps/undici/undici:8812:20) at [Intercepted Dispatch] (node:internal/deps/undici/undici:5673:16) at Client.dispatch (node:internal/deps/undici/undici:5689:44) at [dispatch] (node:internal/deps/undici/undici:5920:32) at [Intercepted Dispatch] (node:internal/deps/undici/undici:5666:33) Node.js process exited with exit status: 129. The logs above can help with debugging the issue.

Damola18 avatar Jun 11 '24 14:06 Damola18

@Damola18 please open a new GitHub issue and fill out the issue template! We can take a look to see what the issue is.

Please also add the output of npm list @sentry/nextjs to that issue.

AbhiPrasad avatar Jun 11 '24 14:06 AbhiPrasad

@Damola18 please open a new GitHub issue and fill out the issue template! We can take a look to see what the issue is.

Please also add the output of npm list @sentry/nextjs to that issue.

Will do that

Damola18 avatar Jun 11 '24 14:06 Damola18

@Damola18 please open a new GitHub issue and fill out the issue template! We can take a look to see what the issue is.

Please also add the output of npm list @sentry/nextjs to that issue.

Will do that

@AbhiPrasad already did

Damola18 avatar Jun 11 '24 15:06 Damola18