Skip to content

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

Closed
@AbhiPrasad

Description

@AbhiPrasad

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.

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