@@ -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 ;
@@ -103,6 +110,7 @@ export function constructWebpackConfigFunction(
103
110
pagesDir,
104
111
pageExtensionRegex,
105
112
excludeServerRoutes : userSentryOptions . excludeServerRoutes ,
113
+ isEdgeRuntime : buildContext . nextRuntime === 'edge' ,
106
114
} ,
107
115
} ,
108
116
] ,
@@ -306,7 +314,15 @@ async function addSentryToEntryProperty(
306
314
307
315
// inject into all entry points which might contain user's code
308
316
for ( const entryPointName in newEntryProperty ) {
309
- if ( shouldAddSentryToEntryPoint ( entryPointName , isServer , userSentryOptions . excludeServerRoutes , isDev ) ) {
317
+ if (
318
+ shouldAddSentryToEntryPoint (
319
+ entryPointName ,
320
+ isServer ,
321
+ userSentryOptions . excludeServerRoutes ,
322
+ isDev ,
323
+ buildContext . nextRuntime === 'edge' ,
324
+ )
325
+ ) {
310
326
addFilesToExistingEntryPoint ( newEntryProperty , entryPointName , filesToInject ) ;
311
327
} else {
312
328
if (
@@ -433,7 +449,13 @@ function shouldAddSentryToEntryPoint(
433
449
isServer : boolean ,
434
450
excludeServerRoutes : Array < string | RegExp > = [ ] ,
435
451
isDev : boolean ,
452
+ isEdgeRuntime : boolean ,
436
453
) : boolean {
454
+ // We don't support the Edge runtime yet
455
+ if ( isEdgeRuntime ) {
456
+ return false ;
457
+ }
458
+
437
459
// On the server side, by default we inject the `Sentry.init()` code into every page (with a few exceptions).
438
460
if ( isServer ) {
439
461
const entryPointRoute = entryPointName . replace ( / ^ p a g e s / , '' ) ;
@@ -530,7 +552,13 @@ export function getWebpackPluginOptions(
530
552
stripPrefix : [ 'webpack://_N_E/' ] ,
531
553
urlPrefix,
532
554
entries : ( entryPointName : string ) =>
533
- shouldAddSentryToEntryPoint ( entryPointName , isServer , userSentryOptions . excludeServerRoutes , isDev ) ,
555
+ shouldAddSentryToEntryPoint (
556
+ entryPointName ,
557
+ isServer ,
558
+ userSentryOptions . excludeServerRoutes ,
559
+ isDev ,
560
+ buildContext . nextRuntime === 'edge' ,
561
+ ) ,
534
562
release : getSentryRelease ( buildId ) ,
535
563
dryRun : isDev ,
536
564
} ) ;
0 commit comments