@@ -85,6 +85,13 @@ export function constructWebpackConfigFunction(
8585 // Add a loader which will inject code that sets global values
8686 addValueInjectionLoader ( newConfig , userNextConfig , userSentryOptions ) ;
8787
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+
8895 if ( isServer ) {
8996 if ( userSentryOptions . autoInstrumentServerFunctions !== false ) {
9097 const pagesDir = newConfig . resolve ?. alias ?. [ 'private-next-pages' ] as string ;
@@ -102,6 +109,7 @@ export function constructWebpackConfigFunction(
102109 pagesDir,
103110 pageExtensionRegex,
104111 excludeServerRoutes : userSentryOptions . excludeServerRoutes ,
112+ isEdgeRuntime : buildContext . nextRuntime === 'edge' ,
105113 } ,
106114 } ,
107115 ] ,
@@ -305,7 +313,15 @@ async function addSentryToEntryProperty(
305313
306314 // inject into all entry points which might contain user's code
307315 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+ ) {
309325 addFilesToExistingEntryPoint ( newEntryProperty , entryPointName , filesToInject ) ;
310326 } else {
311327 if (
@@ -432,7 +448,13 @@ function shouldAddSentryToEntryPoint(
432448 isServer : boolean ,
433449 excludeServerRoutes : Array < string | RegExp > = [ ] ,
434450 isDev : boolean ,
451+ isEdgeRuntime : boolean ,
435452) : boolean {
453+ // We don't support the Edge runtime yet
454+ if ( isEdgeRuntime ) {
455+ return false ;
456+ }
457+
436458 // On the server side, by default we inject the `Sentry.init()` code into every page (with a few exceptions).
437459 if ( isServer ) {
438460 const entryPointRoute = entryPointName . replace ( / ^ p a g e s / , '' ) ;
@@ -529,7 +551,13 @@ export function getWebpackPluginOptions(
529551 stripPrefix : [ 'webpack://_N_E/' ] ,
530552 urlPrefix,
531553 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+ ) ,
533561 release : getSentryRelease ( buildId ) ,
534562 dryRun : isDev ,
535563 } ) ;
0 commit comments