Skip to content

Conversation

@chargome
Copy link
Member

@chargome chargome commented Jan 9, 2026

Fix Next.js Edge build warnings caused by OpenTelemetry’s process.argv0 usage by ensuring OTEL deps are bundled/rewritten in @sentry/vercel-edge and by removing unnecessary @sentry/opentelemetry imports from @sentry/nextjs Edge/shared utilities.

closes #18755

@chargome chargome requested a review from andreiborza January 9, 2026 10:49
@chargome chargome self-assigned this Jan 9, 2026
@linear
Copy link

linear bot commented Jan 9, 2026


// This key must match `@sentry/opentelemetry`'s `SENTRY_SCOPES_CONTEXT_KEY`.
// We duplicate it here so the Edge bundle does not need to import the full `@sentry/opentelemetry` package.
const SENTRY_SCOPES_CONTEXT_KEY = createContextKey('sentry_scopes');

This comment was marked as outdated.

// &&=
out = out.replace(/([A-Za-z_$][\w$]*(?:\[[^\]]+\]|\.[A-Za-z_$][\w$]*)+)\s*&&=\s*([^;]+);/g, (_m, left, right) => {
return `${left} = ${left} && ${right};`;
});
Copy link

Choose a reason for hiding this comment

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

Regex transformation breaks operator precedence with ternary expressions

Medium Severity

The downlevelLogicalAssignmentsPlugin regex transformation produces semantically different code when the right-hand side contains a ternary expression. For example, obj.foo ??= cond ? a : b; becomes obj.foo = obj.foo ?? cond ? a : b;. Due to operator precedence (?? binds tighter than ?:), this is parsed as (obj.foo ?? cond) ? a : b rather than obj.foo ?? (cond ? a : b). The transformation needs to wrap the captured right value in parentheses: ${left} = ${left} ?? (${right}); to preserve the original semantics.

Fix in Cursor Fix in Web

@chargome chargome requested a review from logaretm January 9, 2026 12:24
Copy link
Collaborator

@logaretm logaretm left a comment

Choose a reason for hiding this comment

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

is this a temporary measure till they fix it or...

LGTM anyways to unblock us

@andreiborza
Copy link
Member

Don't think they'll fix this, there's nothing to fix from their POV. I don't think they have edge support on their agenda.

I think we need to leave some comments in the vendored functions we imported from the other sentry packages to reflect that any changes in them also have to be done in our vercel-edge sdk.


// This key must match `@sentry/opentelemetry`'s `SENTRY_SCOPES_CONTEXT_KEY`.
// We duplicate it here so the Edge bundle does not need to import the full `@sentry/opentelemetry` package.
const SENTRY_SCOPES_CONTEXT_KEY = createContextKey('sentry_scopes');
Copy link

Choose a reason for hiding this comment

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

Context key mismatch breaks scope lookup in Edge

High Severity

The createContextKey function from @opentelemetry/api uses Symbol() (not Symbol.for()), so each call creates a unique symbol. The local SENTRY_SCOPES_CONTEXT_KEY created here will be a different symbol than the one created in @sentry/opentelemetry, despite having the same description. This means getScopesFromContext will always return undefined because the context was set using @sentry/opentelemetry's symbol but is being read with a different symbol. The isolation scope mutation in lines 138-140 will silently fail, breaking scope isolation for Edge runtime requests.

Additional Locations (1)

Fix in Cursor Fix in Web

@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 8,660 - 9,254 -6%
GET With Sentry 1,713 20% 1,770 -3%
GET With Sentry (error only) 6,003 69% 6,023 -0%
POST Baseline 1,180 - 1,204 -2%
POST With Sentry 598 51% 597 +0%
POST With Sentry (error only) 1,051 89% 1,048 +0%
MYSQL Baseline 3,259 - 3,318 -2%
MYSQL With Sentry 478 15% 500 -4%
MYSQL With Sentry (error only) 2,665 82% 2,720 -2%

View base workflow run

Copy link
Member

@andreiborza andreiborza left a comment

Choose a reason for hiding this comment

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

Not pretty but alas..

@chargome chargome merged commit fae3a77 into develop Jan 9, 2026
148 checks passed
@chargome chargome deleted the cg/JS-1430/vercel-edge-using-nodejs-api branch January 9, 2026 13:58
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.

vercel-edge using node.js api

5 participants