Skip to content

Conversation

andreiborza
Copy link
Member

@andreiborza andreiborza commented Aug 29, 2025

This issue is only observed for Nextjs 13 and specifically for apps that don't use the app router. Similarly to what we do in vercel-edge, we polyfill performance. This is only done for dev mode as it's not an issue otherwise.

Note: I tried to reproduce this via our existing e2e test apps but they're all using the app router so it's not manifesting there.

Closes: #17343

@andreiborza andreiborza force-pushed the ab/nextjs-edge-dev branch 4 times, most recently from a945362 to 56b2b9f Compare September 8, 2025 08:19
@andreiborza andreiborza marked this pull request as ready for review September 8, 2025 18:03
Copy link
Member

@RulaKhaled RulaKhaled left a comment

Choose a reason for hiding this comment

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

Nice work, just quick comments/questions

DefinePlugin: class {} as any,
ProvidePlugin: class {
constructor(public definitions: Record<string, any>) {}
} as any,
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Can we use a more precise type? or type this with unknown instead of any please?

Copy link
Member Author

Choose a reason for hiding this comment

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

These are just test fixtures, I don't think it's necessary to be more precise here.

addOtelWarningIgnoreRule(newConfig);

// Add edge runtime polyfills when building for edge in dev mode
if (runtime === 'edge' && isDev) {
Copy link
Member

Choose a reason for hiding this comment

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

This will run for all next versions with dev mode correct? is this intended?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, I'll have a look if I can scope this to 13 only.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated to only take 13 into account.

// Ensure performance global is available
if (typeof globalThis !== 'undefined' && globalThis.performance === undefined) {
globalThis.performance = {
timeOrigin: 0,
Copy link
Member

Choose a reason for hiding this comment

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

Maybe do:

 const timeOrigin = Date.now();
  return {
    timeOrigin,
    now: () => Date.now() - timeOrigin,
  };

I think anyone doing timing assertions in dev might see different values

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, updated.

cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

github-actions bot commented Sep 11, 2025

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,919 - 9,388 -5%
GET With Sentry 1,251 14% 1,300 -4%
GET With Sentry (error only) 6,021 68% 6,248 -4%
POST Baseline 1,205 - 1,215 -1%
POST With Sentry 480 40% 535 -10%
POST With Sentry (error only) 1,061 88% 1,072 -1%
MYSQL Baseline 3,357 - 3,421 -2%
MYSQL With Sentry 428 13% 431 -1%
MYSQL With Sentry (error only) 2,712 81% 2,786 -3%

View base workflow run

Copy link
Member

@RulaKhaled RulaKhaled left a comment

Choose a reason for hiding this comment

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

thanks!

@andreiborza andreiborza merged commit 4f38b4b into develop Sep 11, 2025
1080 of 1087 checks passed
@andreiborza andreiborza deleted the ab/nextjs-edge-dev branch September 11, 2025 16:40
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.

Performance is not defined - sentry with NextJS
2 participants