-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
If a "page prop" has a circular structure, a silent unhandled promise rejection will occur in NextScript#render
#4812
Comments
|
I wonder why Either way we should catch errors when rendering _error, so this is a bug |
webpackDevMiddleware config - turned off quiet and noInfo
|
🤔 that's a compilation error coming from webpack, I wonder how it would call |
Maybe we can check this and alert the user. |
This might be useful for dealing with circular stuff: https://www.npmjs.com/package/circular-json |
Ran into this again with the nextI18n example. Its very easy to accidentally pass a circular json when working with getInitialProps. |
@nisargrthakkar you're not providing any context, it's unlikely you're running into the same issue as Vaughan, and if that is the case GitHub has the 👍 feature to make that know 🙏 |
This was solved recently: https://github.com/zeit/next.js/blob/canary/packages/next/pages/_document.js#L326-L332 |
Bug report
Describe the bug
If a "page prop" has a circular structure, a silent unhandled promise rejection will occur in
NextScript#render
To Reproduce
To reproduce, add a custom
_error
page, and return theerr
object ingetInitialProps
. This object has a circular structure. Or create an object with circular structure.Use a custom server, and add
require('hard-rejection')()
to the start of your server code.Then make a syntax error on a page.
You should see the following message:
I tried to catch it in
_document.js#componentDidCatch
but it did not work.It was very difficult to trace down the cause of this...and hence why my error page would never show (I didn't realize it was broken).
Expected behavior
Helpful message should be shown indicating there is a circular dep issue, and what property is the cause of it.
Also should not be an unhandled promise rejection...
Potential solution
Try/catch should be placed around htmlescape, and an error message should be
PS. Why doesn't
componentDidCatch
in_document
catch this? Is it something to do with_document
only running SS?System information
The text was updated successfully, but these errors were encountered: