Skip to content
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

fix(nextjs): Don't write to res.end to fix next export #6682

Merged
merged 1 commit into from Jan 9, 2023

Conversation

lforst
Copy link
Member

@lforst lforst commented Jan 7, 2023

Fixes #6088

When running next export when having a custom _error page and a custom 404 page, Next.js will call the _error's getInitialProps. In this call, a special res object seems to be passed that doesn't have a .end() method.

This PR fixes a bug where we're trying to access that .end property even though it doesn't exist by simply checking for it first. Since exporting will create static pages we don't need to patch .end anyways.

@lforst lforst marked this pull request as ready for review January 9, 2023 09:50
@lforst lforst requested review from mydea and Lms24 January 9, 2023 09:50
Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this call, a special res object seems to be passed that doesn't have a .end() method

This seems like a bug with next, isn't response.end part of the node std library response? Or is this a case where the res might be an plain object, and not one with methods.

@lforst
Copy link
Member Author

lforst commented Jan 9, 2023

In this call, a special res object seems to be passed that doesn't have a .end() method

This seems like a bug with next, isn't response.end part of the node std library response? Or is this a case where the res might be an plain object, and not one with methods.

I think in the case of next export we don't really have actual requests & responses because it is just a static export so the passed res and req simply options don't have these methods. I have to admit though, I didn't look at Next.js code for this fix.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.84 KB (-0.01% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 61.46 KB (+0.03% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.62 KB (0%)
@sentry/browser - ES6 CDN Bundle (minified) 55 KB (+0.02% 🔺)
@sentry/browser - Webpack (gzipped + minified) 20.38 KB (-0.05% 🔽)
@sentry/browser - Webpack (minified) 66.55 KB (-0.14% 🔽)
@sentry/react - Webpack (gzipped + minified) 20.4 KB (-0.03% 🔽)
@sentry/nextjs Client - Webpack (gzipped + minified) 47.67 KB (-0.03% 🔽)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.82 KB (+0.03% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 25.25 KB (-0.01% 🔽)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 43 KB (+0.03% 🔺)
@sentry/replay - Webpack (gzipped + minified) 38.25 KB (+0.04% 🔺)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

next export fails when having _error and 404 page
3 participants