Skip to content

Add reproduction for sentry-javascript#19367#21

Open
chargome wants to merge 2 commits intomainfrom
repro/sentry-javascript-19367
Open

Add reproduction for sentry-javascript#19367#21
chargome wants to merge 2 commits intomainfrom
repro/sentry-javascript-19367

Conversation

@chargome
Copy link
Member

Reproduces: Next.js 16 + Turbopack duplicates @opentelemetry/api across server-side chunks, causing infinite .with() recursion and a fatal RangeError: Maximum call stack size exceeded.

The check-otel-dedup script confirms 7 duplicate OTel chunks in the build output, matching the root cause described in the issue.

chargome and others added 2 commits February 18, 2026 15:27
Reproduces: Next.js 16 + Turbopack duplicates @opentelemetry/api across
server-side chunks, causing infinite .with() recursion and a fatal
RangeError: Maximum call stack size exceeded.

The check-otel-dedup script confirms 7 duplicate OTel chunks in the build
output, matching the root cause described in the issue.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Merge all investigation findings into README.md, add diagnostic route
(/api/otel-check), enhanced check-otel-dedup script that maps per-route
chunk loading, force-crash.js for isolated testing, and realistic nested
Sentry.startSpan() route. Add .next/ and next-env.d.ts to .gitignore.

Key findings: Turbopack duplication is confirmed and deterministic but
the actual RangeError crash could not be triggered locally -- likely
requires Node.js v24, real Prisma queries, or sustained production traffic.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

"instances instead of deduplicating into a single shared chunk.";

return NextResponse.json(diagnostics, {
status: contextWithResult.startsWith("CRASH") ? 500 : 200,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Status code ignores the nested crash test result

Medium Severity

The HTTP status code is determined solely by contextWithResult (the single context.with() test), but ignores nestedResult (the 3-deep nested test). The nested test is the one that mimics _startSpan()'s pattern from SDK 10.38.0 — the exact scenario that triggers the infinite recursion crash. If the simple test passes but the nested test crashes, the endpoint returns 200 instead of 500, making automated detection of the bug's primary failure mode impossible.

Additional Locations (1)

Fix in Cursor Fix in Web

* context.with() path the way @sentry/opentelemetry's _startSpan() does.
*/

const Module = require("module");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused Module import in force-crash script

Low Severity

Module is required from "module" but never referenced anywhere in the file. This is dead code that can be removed.

Fix in Cursor Fix in Web

const chunks = (content.match(/R\.c\("([^"]+)"\)/g) || []).map(m => m.match(/"([^"]+)"/)[1]);
const routeName = rf.replace(serverDir + "/app", "").replace(/\/(route|page)\.js$/, "") || "/";
routes[routeName] = chunks;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Route chunks miss dynamic chunk refs, causing false negatives

Medium Severity

The instrumentation entry point analysis follows two levels of chunk references — it collects static R.c() refs and then scans those chunks for dynamic e.l() refs (lines 43–53). Route entry points only collect static R.c() refs (line 72) and never resolve dynamic chunk refs within those. This asymmetry means any @opentelemetry/api code loaded through a route's dynamic chunks is invisible to the duplication comparison, potentially producing false negatives in the diagnostic output.

Additional Locations (1)

Fix in Cursor Fix in Web

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant