@@ -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 ;
@@ -103,6 +110,7 @@ export function constructWebpackConfigFunction(
103110 pagesDir,
104111 pageExtensionRegex,
105112 excludeServerRoutes : userSentryOptions . excludeServerRoutes ,
113+ isEdgeRuntime : buildContext . nextRuntime === 'edge' ,
106114 } ,
107115 } ,
108116 ] ,
@@ -306,7 +314,15 @@ async function addSentryToEntryProperty(
306314
307315 // inject into all entry points which might contain user's code
308316 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+ ) {
310326 addFilesToExistingEntryPoint ( newEntryProperty , entryPointName , filesToInject ) ;
311327 } else {
312328 if (
@@ -433,7 +449,13 @@ function shouldAddSentryToEntryPoint(
433449 isServer : boolean ,
434450 excludeServerRoutes : Array < string | RegExp > = [ ] ,
435451 isDev : boolean ,
452+ isEdgeRuntime : boolean ,
436453) : boolean {
454+ // We don't support the Edge runtime yet
455+ if ( isEdgeRuntime ) {
456+ return false ;
457+ }
458+
437459 // On the server side, by default we inject the `Sentry.init()` code into every page (with a few exceptions).
438460 if ( isServer ) {
439461 const entryPointRoute = entryPointName . replace ( / ^ p a g e s / , '' ) ;
@@ -530,7 +552,13 @@ export function getWebpackPluginOptions(
530552 stripPrefix : [ 'webpack://_N_E/' ] ,
531553 urlPrefix,
532554 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+ ) ,
534562 release : getSentryRelease ( buildId ) ,
535563 dryRun : isDev ,
536564 } ) ;
0 commit comments