Skip to content

next export fails when having _error and 404 page #6088

Closed
@bas080

Description

@bas080

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/nextjs

SDK Version

7.17.2

Framework Version

13.0.0

Link to Sentry event

No response

Steps to Reproduce

Versions

jq .version  < ./node_modules/next/package.json
jq .version  < ./node_modules/@sentry/nextjs/package.json
"13.0.0"
"7.17.2"

Reproduce

npm run build && npm run export

> [email protected] build
> next build

warn  - You have enabled experimental feature (cpus) in next.config.mjs.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.

info  - Linting and checking validity of types...
info  - Creating an optimized production build...
info  - Compiled successfully
info  - Collecting page data...
info  - Generating static pages (0/53)
info  - Generating static pages (13/53)
info  - Generating static pages (26/53)
info  - Generating static pages (39/53)
info  - Generating static pages (53/53)
info  - Finalizing page optimization...

Route (pages)                                         Size     First Load JS
┌   /_app                                             0 B             109 kB
├ ● /[language]/[webpage] (ISR: 1 Seconds) (8775 ms)  13.7 kB         128 kB
├   ├ /ru/404 (334 ms)
├   ├ /en/index
├   ├ /he/index
├   ├ /ru/index
├   ├ /en/boat-hire
├   ├ /he/boat-hire
├   ├ /ru/boat-hire
├   └ [+44 more paths]
├ λ /404                                              438 B           109 kB
├ λ /api/[sheet]/[gid]/invalidate                     0 B             109 kB
├ λ /api/[sheet]/[gid]/json                           0 B             109 kB
├ λ /api/email/[language]/[webpage]                   0 B             109 kB
├ λ /api/email/[language]/[webpage]/send              0 B             109 kB
├ λ /api/form/[language]/[webpage]                    0 B             109 kB
├ λ /api/ping                                         0 B             109 kB
├ λ /api/publish                                      0 B             109 kB
├ ● /public/robots.txt                                541 B           115 kB
└ ● /public/sitemap.xml (2449 ms)                     543 B           115 kB
+ First Load JS shared by all                         114 kB
  ├ chunks/framework-3b5a00d5d7e8d93b.js              45.4 kB
  ├ chunks/main-109639d04b48b523.js                   29.4 kB
  ├ chunks/pages/_app-8141b332980f9e18.js             32.1 kB
  ├ chunks/webpack-32ca610b9890a2c4.js                1.81 kB
  └ css/77ad3477c6267d74.css                          5.55 kB

λ  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)
   (ISR)     incremental static regeneration (uses revalidate in getStaticProps)


> [email protected] export
> next export --threads 1

warn  - You have enabled experimental feature (cpus) in next.config.mjs.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.

info  - using build directory: /home/ant/projects/localu/.next
warn  - rewrites, redirects, and headers are not applied when exporting your application, detected (rewrites, redirects). See more info here: https://nextjs.org/docs/messages/export-no-custom-routes
info  - Copying "static build" directory
info  - No "exportPathMap" found in "/home/ant/projects/localu/next.config.mjs". Generating map from "./pages"
info  - Launching 1 workers
warn  - Statically exporting a Next.js application via `next export` disables API routes.
This command is meant for static-only hosts, and is not necessary to make your application static.
Pages in your application without server-side data dependencies will be automatically statically exported by `next build`, including pages powered by `getStaticProps`.
Learn more: https://nextjs.org/docs/messages/api-routes-static-export
info  - Exporting (0/4)
info  - Copying "public" directory
info  - Exporting (1/4)
info  - Exporting (2/4)
warn  - Detected getInitialProps on page '/_error' while running "next export". It's recommended to use getStaticProps which has a more correct behavior for static exporting.
Read more: https://nextjs.org/docs/messages/get-initial-props-export

Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Cannot read properties of undefined (reading '__sentry_original__')
    at Object.autoEndTransactionOnResponseEnd (/home/ant/projects/localu/node_modules/@sentry/nextjs/cjs/config/wrappers/utils/responseEnd.js:34:19)
    at /home/ant/projects/localu/node_modules/@sentry/nextjs/cjs/config/wrappers/wrapperUtils.js:92:19
    at bound (node:domain:433:15)
    at runBound (node:domain:444:12)
    at Object.callTracedServerSideDataFetcher (/home/ant/projects/localu/node_modules/@sentry/nextjs/cjs/config/wrappers/wrapperUtils.js:128:5)
    at Function.getInitialProps (/home/ant/projects/localu/node_modules/@sentry/nextjs/cjs/config/wrappers/withSentryServerSideErrorGetInitialProps.js:38:23)
    at /home/ant/projects/localu/node_modules/next/dist/shared/lib/utils.js:84:33
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/home/ant/projects/localu/node_modules/@swc/helpers/lib/_async_to_generator.js:23:28)
    at _next (/home/ant/projects/localu/node_modules/@swc/helpers/lib/_async_to_generator.js:12:17)
info  - Exporting (3/4)
warn  - Detected getInitialProps on page '/_error' while running "next export". It's recommended to use getStaticProps which has a more correct behavior for static exporting.
Read more: https://nextjs.org/docs/messages/get-initial-props-export

Error occurred prerendering page "/404.html". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Cannot read properties of undefined (reading '__sentry_original__')
    at Object.autoEndTransactionOnResponseEnd (/home/ant/projects/localu/node_modules/@sentry/nextjs/cjs/config/wrappers/utils/responseEnd.js:34:19)
    at /home/ant/projects/localu/node_modules/@sentry/nextjs/cjs/config/wrappers/wrapperUtils.js:92:19
    at bound (node:domain:433:15)
    at runBound (node:domain:444:12)
    at Object.callTracedServerSideDataFetcher (/home/ant/projects/localu/node_modules/@sentry/nextjs/cjs/config/wrappers/wrapperUtils.js:128:5)
    at Function.getInitialProps (/home/ant/projects/localu/node_modules/@sentry/nextjs/cjs/config/wrappers/withSentryServerSideErrorGetInitialProps.js:38:23)
    at /home/ant/projects/localu/node_modules/next/dist/shared/lib/utils.js:84:33
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/home/ant/projects/localu/node_modules/@swc/helpers/lib/_async_to_generator.js:23:28)
    at _next (/home/ant/projects/localu/node_modules/@swc/helpers/lib/_async_to_generator.js:12:17)
info  - Exporting (4/4)
Error: Export encountered errors on following paths:
	/_error: /404
	/_error: /404.html
    at /home/ant/projects/localu/node_modules/next/dist/export/index.js:405:19
    at async Span.traceAsyncFn (/home/ant/projects/localu/node_modules/next/dist/trace/trace.js:79:20)

Notice that the export fails.

Expected Result

That all pages are built

Actual Result

It errors for the _error page.

Metadata

Metadata

Assignees

Labels

Package: nextjsIssues related to the Sentry Nextjs SDK

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions