Skip to content

Can the 'next js-page extensions' be applied in @sentry/nextjs? #5877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AbhiPrasad opened this issue Oct 4, 2022 Discussed in #5876 · 2 comments · Fixed by #5881
Closed

Can the 'next js-page extensions' be applied in @sentry/nextjs? #5877

AbhiPrasad opened this issue Oct 4, 2022 Discussed in #5876 · 2 comments · Fixed by #5881
Assignees
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK

Comments

@AbhiPrasad
Copy link
Member

Discussed in #5876

Originally posted by ccj9707 October 4, 2022
Hello. My project is based on nextjs, and the pages/ directory structure is as follows.

sample
├ sample.page.tsx (page component)
├ sample.styles.ts (only css)
└ sample.util.ts (only function)
_app.page.tsx
_document.page.tsx

I am using the custom page extensions feature of nextjs.
https://nextjs.org/docs/api-reference/next.config.js/custom-page-extensions

// next.config.js
pageExtensions: ['page.tsx', 'page.ts'],

When I tried to build the project after adding sentry/nextjs through the wizard, the following error occurred.

> Build error occurred
TypeError: Cannot read property 'getInitialProps' of undefined

I followed the stack trace and found that there was a problem with the code in /.next/server/chunks.

var userPageModule = constants_sentry_wrapped_namespaceObject;
var pageComponent = userPageModule.default;
var origGetInitialProps = pageComponent.getInitialProps;

sample_styles_sentry_wrapped_namespaceObject had the following comments:

// NAMESPACE OBJECT: ./pages/sample/sample.styles.ts?__sentry_wrapped_

It looked like there was no getInitialProps because it wasn't a page component.

@AbhiPrasad AbhiPrasad added Package: nextjs Issues related to the Sentry Nextjs SDK Type: Bug labels Oct 4, 2022
@lforst lforst self-assigned this Oct 4, 2022
@lforst
Copy link
Contributor

lforst commented Oct 4, 2022

@ccj9707 Thanks for reporting this! In the meanwhile to get your stuff working again, you can set autoInstrumentServerFunctions: false in your Next.js config.

We didn't really consider custom page extensions when building this feature but we'll try to get a fix out asap.

@frontend-changjin-choi
Copy link

@lforst Thank you very much for providing an immediate solution regarding the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK
Projects
None yet
3 participants