rsnext/errors/circular-structure.md
Tom 5262594cd7
Add note about req to circular-structure error doc (#47162)
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-03-27 03:44:31 +00:00

682 B

Circular structure in "getInitialProps" result

Why This Error Occurred

getInitialProps is serialized to JSON using JSON.stringify and sent to the client side for hydrating the page.

However, the result returned from getInitialProps can't be serialized when it has a circular structure.

Possible Ways to Fix It

Circular structures are not supported, so the way to fix this error is removing the circular structure from the object that is returned from getInitialProps.

For example, the req instance exposed is a circular object and can not be serialized, instead the specific fields such as relevant headers on the instance should be passed specifically.