@@ -85,6 +85,13 @@ export function constructWebpackConfigFunction(
85
85
// Add a loader which will inject code that sets global values
86
86
addValueInjectionLoader ( newConfig , userNextConfig , userSentryOptions ) ;
87
87
88
+ if ( buildContext . nextRuntime === 'edge' ) {
89
+ // eslint-disable-next-line no-console
90
+ console . warn (
91
+ '[@sentry/nextjs] You are using edge functions or middleware. Please note that Sentry does not yet support error monitoring for these features.' ,
92
+ ) ;
93
+ }
94
+
88
95
if ( isServer ) {
89
96
if ( userSentryOptions . autoInstrumentServerFunctions !== false ) {
90
97
const pagesDir = newConfig . resolve ?. alias ?. [ 'private-next-pages' ] as string ;
@@ -102,6 +109,7 @@ export function constructWebpackConfigFunction(
102
109
pagesDir,
103
110
pageExtensionRegex,
104
111
excludeServerRoutes : userSentryOptions . excludeServerRoutes ,
112
+ isEdgeRuntime : buildContext . nextRuntime === 'edge' ,
105
113
} ,
106
114
} ,
107
115
] ,
@@ -305,7 +313,15 @@ async function addSentryToEntryProperty(
305
313
306
314
// inject into all entry points which might contain user's code
307
315
for ( const entryPointName in newEntryProperty ) {
308
- if ( shouldAddSentryToEntryPoint ( entryPointName , isServer , userSentryOptions . excludeServerRoutes , isDev ) ) {
316
+ if (
317
+ shouldAddSentryToEntryPoint (
318
+ entryPointName ,
319
+ isServer ,
320
+ userSentryOptions . excludeServerRoutes ,
321
+ isDev ,
322
+ buildContext . nextRuntime === 'edge' ,
323
+ )
324
+ ) {
309
325
addFilesToExistingEntryPoint ( newEntryProperty , entryPointName , filesToInject ) ;
310
326
} else {
311
327
if (
@@ -432,7 +448,13 @@ function shouldAddSentryToEntryPoint(
432
448
isServer : boolean ,
433
449
excludeServerRoutes : Array < string | RegExp > = [ ] ,
434
450
isDev : boolean ,
451
+ isEdgeRuntime : boolean ,
435
452
) : boolean {
453
+ // We don't support the Edge runtime yet
454
+ if ( isEdgeRuntime ) {
455
+ return false ;
456
+ }
457
+
436
458
// On the server side, by default we inject the `Sentry.init()` code into every page (with a few exceptions).
437
459
if ( isServer ) {
438
460
const entryPointRoute = entryPointName . replace ( / ^ p a g e s / , '' ) ;
@@ -529,7 +551,13 @@ export function getWebpackPluginOptions(
529
551
stripPrefix : [ 'webpack://_N_E/' ] ,
530
552
urlPrefix,
531
553
entries : ( entryPointName : string ) =>
532
- shouldAddSentryToEntryPoint ( entryPointName , isServer , userSentryOptions . excludeServerRoutes , isDev ) ,
554
+ shouldAddSentryToEntryPoint (
555
+ entryPointName ,
556
+ isServer ,
557
+ userSentryOptions . excludeServerRoutes ,
558
+ isDev ,
559
+ buildContext . nextRuntime === 'edge' ,
560
+ ) ,
533
561
release : getSentryRelease ( buildId ) ,
534
562
dryRun : isDev ,
535
563
} ) ;
0 commit comments