@@ -28,6 +28,13 @@ const RUNTIME_TO_SDK_ENTRYPOINT_MAP = {
28
28
edge : './edge' ,
29
29
} as const ;
30
30
31
+ // Next.js runs webpack 3 times, once for the client, the server, and for edge. Because we don't want to print certain
32
+ // warnings 3 times, we keep track of them here.
33
+ let showedMissingAuthTokenErrorMsg = false ;
34
+ let showedMissingOrgSlugErrorMsg = false ;
35
+ let showedMissingProjectSlugErrorMsg = false ;
36
+ let showedHiddenSourceMapsWarningMsg = false ;
37
+
31
38
// TODO: merge default SentryWebpackPlugin ignore with their SentryWebpackPlugin ignore or ignoreFile
32
39
// TODO: merge default SentryWebpackPlugin include with their SentryWebpackPlugin include
33
40
// TODO: drop merged keys from override check? `includeDefaults` option?
@@ -649,12 +656,15 @@ export function getWebpackPluginOptions(
649
656
) } environment variable during the build.`;
650
657
}
651
658
652
- // eslint-disable-next-line no-console
653
- console . error (
654
- `${ errorMessagePrefix } ${ chalk . bold (
655
- 'No Sentry auth token configured.' ,
656
- ) } Source maps will not be uploaded.\n${ msg } \n`,
657
- ) ;
659
+ if ( ! showedMissingAuthTokenErrorMsg ) {
660
+ // eslint-disable-next-line no-console
661
+ console . error (
662
+ `${ errorMessagePrefix } ${ chalk . bold (
663
+ 'No Sentry auth token configured.' ,
664
+ ) } Source maps will not be uploaded.\n${ msg } \n`,
665
+ ) ;
666
+ showedMissingAuthTokenErrorMsg = true ;
667
+ }
658
668
659
669
return ;
660
670
}
@@ -672,12 +682,15 @@ export function getWebpackPluginOptions(
672
682
) } environment variable to the to your organization slug during the build.`;
673
683
}
674
684
675
- // eslint-disable-next-line no-console
676
- console . error (
677
- `${ errorMessagePrefix } ${ chalk . bold (
678
- 'No Sentry organization slug configured.' ,
679
- ) } Source maps will not be uploaded.\n${ msg } \n`,
680
- ) ;
685
+ if ( ! showedMissingOrgSlugErrorMsg ) {
686
+ // eslint-disable-next-line no-console
687
+ console . error (
688
+ `${ errorMessagePrefix } ${ chalk . bold (
689
+ 'No Sentry organization slug configured.' ,
690
+ ) } Source maps will not be uploaded.\n${ msg } \n`,
691
+ ) ;
692
+ showedMissingOrgSlugErrorMsg = true ;
693
+ }
681
694
682
695
return ;
683
696
}
@@ -695,12 +708,15 @@ export function getWebpackPluginOptions(
695
708
) } environment variable to the name of your Sentry project during the build.`;
696
709
}
697
710
698
- // eslint-disable-next-line no-console
699
- console . error (
700
- `${ errorMessagePrefix } ${ chalk . bold (
701
- 'No Sentry project slug configured.' ,
702
- ) } Source maps will not be uploaded.\n${ msg } \n`,
703
- ) ;
711
+ if ( ! showedMissingProjectSlugErrorMsg ) {
712
+ // eslint-disable-next-line no-console
713
+ console . error (
714
+ `${ errorMessagePrefix } ${ chalk . bold (
715
+ 'No Sentry project slug configured.' ,
716
+ ) } Source maps will not be uploaded.\n${ msg } \n`,
717
+ ) ;
718
+ showedMissingProjectSlugErrorMsg = true ;
719
+ }
704
720
705
721
return ;
706
722
}
@@ -775,7 +791,7 @@ function handleSourcemapHidingOptionWarning(userSentryOptions: UserSentryOptions
775
791
const _sentry_ = codeFormat ( 'sentry' ) ;
776
792
const _nextConfigJS_ = codeFormat ( 'next.config.js' ) ;
777
793
778
- if ( isServer && userSentryOptions . hideSourceMaps === undefined ) {
794
+ if ( isServer && userSentryOptions . hideSourceMaps === undefined && ! showedHiddenSourceMapsWarningMsg ) {
779
795
// eslint-disable-next-line no-console
780
796
console . warn (
781
797
`\n${ _warningPrefix_ } In order to be able to deminify errors, ${ _sentryNextjs_ } creates sourcemaps and uploads ` +
@@ -787,6 +803,7 @@ function handleSourcemapHidingOptionWarning(userSentryOptions: UserSentry
5D48
Options
787
803
'https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-hidden-source-map for more ' +
788
804
'information.\n' ,
789
805
) ;
806
+ showedHiddenSourceMapsWarningMsg = true ;
790
807
}
791
808
792
809
// TODO (v8): Remove the check above in favor of the one below
0 commit comments