Skip to content

TypeError: Cannot read properties of null (reading 'toUpperCase') in server HTTP instrumentation when outgoing request times out (Next.js 15, Node 22) #20415

@RipperZA

Description

@RipperZA

What happened

After upgrading @sentry/nextjs from 10.38.0 to 10.49.0, any outgoing HTTPS request from the Next.js server that times out crashes the Node process with an unhandled rejection:

TypeError: Cannot read properties of null (reading 'toUpperCase')
    at <unknown> (build/server/instrumentation.js:22:183677)
    at v.<anonymous> (build/server/instrumentation.js:22:184440)
    at v.emit (node:events:536:35)
    at v.emit (.../next/dist/compiled/@mswjs/interceptors/ClientRequest/index.js:1:5660)
    at v.respondWith (.../next/dist/compiled/@mswjs/interceptors/ClientRequest/index.js:1:7547)
    at .../next/dist/compiled/@mswjs/interceptors/ClientRequest/index.js:1:4533
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

The error originates from the Sentry server instrumentation bundle, triggered by an event emitted from Next's bundled @mswjs/interceptors ClientRequest on request abort/timeout.

Reproduction

  1. Next.js 15.5.15 app with @sentry/nextjs@10.49.0, output: 'standalone', Node 22.
  2. Configure next-auth Keycloak provider (or any outbound HTTP client) with an unreachable URL, e.g. https://10.255.255.1/....
  3. yarn build && node build/standalone/server.js.
  4. Trigger the outgoing request (in our case /api/auth/signin/keycloak).
  5. Request times out after ~3.5s → process crash with the stack above.

Versions tested

  • @sentry/nextjs@10.38.0works (next-auth logs timeout, no process crash)
  • @sentry/nextjs@10.49.0crashes with the TypeError above

Haven't bisected the exact intermediate version yet. Candidates from the changelog:

Environment

  • @sentry/nextjs: 10.49.0
  • next: 15.5.15
  • next-auth: 4.24.7
  • Node: 22.12.0
  • Output mode: standalone

Impact

In production, any transient unreachability of an upstream service (auth provider, API) takes down the Node process instead of just logging the timeout. Currently pinned at 10.38.0.

Metadata

Metadata

Assignees

No fields configured for issues without a type.

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions