Skip to content

nextjs: Network socket closes before events are being flushed on Vercel #14780

Closed
@Yuripetusko

Description

@Yuripetusko

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

8.42.0

Framework Version

react 18.3.1, next 14.2.4

Link to Sentry event

No response

Reproduction Example/SDK Setup

// apps/api/sentry-example-api/route.ts

import { NextResponse } from 'next/server'

export const dynamic = 'force-dynamic'

// A faulty API route to test Sentry's error monitoring
export const GET() {
  throw new Error('Sentry Example API Route Error')
  return NextResponse.json({ data: 'Testing Sentry Error...' })
}

Steps to Reproduce

@sentry/nextjs introduced a bug in version 8.36.0 that broke the auto instrumentation of nextjs api route handlers in next 14.2.4 (maybe other version too) App router.

The error in api route handler is not logged in sentry completly, and as soon as I downgrade to 8.33.0 it works fine. All version from 8.36.0 and up to the latest (8.42.0) have this bug.

Haven't investigated this deeper, but from a quick glance, perhaps this commit was when the issue was introduced?
#14084
Or this f9df1b4

Expected Result

For next: 14.2.4 api route handler unhandled error to be reported in sentry with latest @sentry/nextjs sdk

Actual Result

No error reported in Sentry

Metadata

Metadata

Assignees

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions