Skip to content

Turbopack dev: server stack frames get inverted in_app, and SDK-side fixes are overridden at ingest #23176

Description

@sergical

Environment

@sentry/nextjs 10.69.0, Next.js 16.3.0, next dev (Turbopack), Node server runtime

What happens

When app code throws under next dev (Turbopack), the stored event has in_app backwards: frames from third-party packages show as In App, while the app's own crash frame shows as non-app. The issue page leads with vendor frames and says "Crashed in non-app: lib/…".

in_app: true  | app:///_next/dev/server/chunks/node_modules_ai_dist_index_16zsbns.js   (× 9)
in_app: false | lib/ai/tools.ts        ← the actual crash site

Why

Turbopack's dev chunk naming defeats the SDK's classification:

  1. filenameIsInApp (packages/core/src/utils/node-stack-trace.ts) marks a frame as vendor only if its filename contains node_modules/. Turbopack flattens that to underscores (node_modules_@ai-sdk_…_<hash>.js), so vendor frames count as app code.
  2. The same function treats filenames that don't start with /, a drive letter, ., or a protocol as internal. Turbopack app modules are bracket-prefixed ([project]/…), so app frames count as non-app.
  3. devErrorSymbolicationEventProcessor.ts resolves the app frame back to its real file but keeps the wrong in_app (the ...frame spread); frames it can't resolve get in_app: false.
  4. fix(nextjs): Mark internal chunk frames as not in_app #22354 (10.67.0) fixed the same problem for client-side _next/static/chunks only.

Note for a fix: correcting the classification isn't enough on its own. Sentry's ingest re-derives in_app from frame paths and overwrites whatever the event says (confirmed: a beforeSend that forced correct values ran, yet the stored event was inverted again). The fix needs to change the paths the SDK emits — e.g. restore a real /node_modules/ segment — or ingest's rules need to learn Turbopack's naming.

Reproduce

Throw any error in app code under next dev (Turbopack, Next 16) and check stacktrace.frames[].in_app on the stored event. Ready-made repro: https://github.com/getsentry/sentry-agent-tracing-examples (storefront-commerce has an intentionally failing tool in lib/ai/tools.ts).

Production builds are fine: with source maps uploaded, classification is correct; without them, everything is one minified chunk marked in-app.

Workaround

Project → Settings → Issue Grouping → Stack Trace Rules:

stack.abs_path:app:///_next/dev/server/chunks/** -app
stack.abs_path:**/*.ts +app
stack.abs_path:**/*.tsx +app
stack.abs_path:*.ts +app
stack.abs_path:**/node_modules/** -app

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status
    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions