@@ -144,7 +144,7 @@ async function addSentryToEntryProperty(
144144
145145 // inject into all entry points which might contain user's code
146146 for ( const entryPointName in newEntryProperty ) {
147- if ( shouldAddSentryToEntryPoint ( entryPointName ) ) {
147+ if ( shouldAddSentryToEntryPoint ( entryPointName , isServer ) ) {
148148 addFilesToExistingEntryPoint ( newEntryProperty , entryPointName , filesToInject ) ;
149149 }
150150 }
@@ -251,10 +251,15 @@ function checkWebpackPluginOverrides(
251251 * Determine if this is an entry point into which both `Sentry.init()` code and the release value should be injected
252252 *
253253 * @param entryPointName The name of the entry point in question
254+ * @param isServer Whether or not this function is being called in the context of a server build
254255 * @returns `true` if sentry code should be injected, and `false` otherwise
255256 */
256- function shouldAddSentryToEntryPoint ( entryPointName : string ) : boolean {
257- return entryPointName === 'pages/_app' || entryPointName . includes ( 'pages/api' ) ;
257+ function shouldAddSentryToEntryPoint ( entryPointName : string , isServer : boolean ) : boolean {
258+ return (
259+ entryPointName === 'pages/_app' ||
260+ entryPointName . includes ( 'pages/api' ) ||
261+ ( isServer && entryPointName === 'pages/_error' )
262+ ) ;
258263}
259264
260265/**
@@ -295,7 +300,7 @@ export function getWebpackPluginOptions(
295300 configFile : hasSentryProperties ? 'sentry.properties' : undefined ,
296301 stripPrefix : [ 'webpack://_N_E/' ] ,
297302 urlPrefix,
298- entries : shouldAddSentryToEntryPoint ,
303+ entries : ( entryPointName : string ) => shouldAddSentryToEntryPoint ( entryPointName , isServer ) ,
299304 release : getSentryRelease ( buildId ) ,
300305 dryRun : isDev ,
301306 } ) ;
0 commit comments