Skip to content

Telemetry is delayed or lost when Vercel suspends a Node.js function after the response #24909

Description

@sergical

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

11.1.0

Framework Version

Seen with Next.js 16 on the Vercel Node.js runtime. The cause is not specific to Next.js.

Link to Sentry event

No response

Reproduction Example/SDK Setup

Default server setup:

Sentry.init({
  dsn: '...',
  tracesSampleRate: 1,
});

Steps to Reproduce

  1. Deploy an app that uses the Node.js SDK to Vercel, on the Node.js runtime.
  2. Send one request.
  3. Send no more requests, so the function goes idle.
  4. Look for the request's telemetry in Sentry.

Expected Result

All telemetry of the request (spans, logs, metrics, errors) arrives shortly after the response.

Actual Result

Telemetry that was still buffered when the response was sent arrives late or never. It is sent only when a later request wakes the same instance. With span streaming, the root span of the last request is often missing and its child spans show up without a parent.

Additional Context

Vercel can suspend a function as soon as it sends the response. The SDK sends buffered telemetry on timers or on SIGTERM, and neither runs while the function is suspended.

Vercel provides waitUntil through Symbol.for('@vercel/request-context') on the Node.js runtime, but the SDK uses it only on the Edge runtime.

Fix: #24910. Related: #23087.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions