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 bug with "Circular Structure" error #23905
Conversation
Since `-1` is truthy, every JSON.stringify error is mistaken to be `circular structure`. This commit fixes that behaviour, so that other errors like `Do not know how to serialize Bigint` (see blitz-js/babel-plugin-superjson-next#63) aren't swallowed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add an integration test for this 👍
This may be thought of as being a pretty contrived example, but it's exactly what happened in blitz-js/babel-plugin-superjson-next#63.
} | ||
|
||
export default function Repro(props) { | ||
props.topics[0].number = 22n // basically what happened in https://github.com/blitz-js/babel-plugin-superjson-next/issues/63 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICT, this error really only occurs when props are mutated during rendering. Normal JSON-misuse (e.g. returning bigints from getStaticProps) is catched before by custom Next.js logic.
Mutating during render is a big no-no, so errors that aren't about "circular structure" could even be used to indicate the mistake and point towards the React docs.
Stats from current PRDefault Server Mode (Decrease detected ✓)General Overall increase
|
vercel/next.js canary | Skn0tt/next.js patch-1 | Change | |
---|---|---|---|
buildDuration | 13.9s | 13.8s | -91ms |
nodeModulesSize | 46.7 MB | 46.7 MB |
Page Load Tests Overall decrease ⚠️
vercel/next.js canary | Skn0tt/next.js patch-1 | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.527 | 2.48 | -0.05 |
/ avg req/sec | 989.38 | 1007.99 | +18.61 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.277 | 1.33 | |
/error-in-render avg req/sec | 1958.11 | 1879.54 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | Skn0tt/next.js patch-1 | Change | |
---|---|---|---|
597-3f457946..288d.js gzip | 13.3 kB | 13.3 kB | ✓ |
778-6834d41c..48a9.js gzip | 7.05 kB | 7.05 kB | ✓ |
framework.HASH.js gzip | 39.3 kB | 39.3 kB | ✓ |
main-HASH.js gzip | 151 B | 151 B | ✓ |
webpack-HASH.js gzip | 993 B | 993 B | ✓ |
Overall change | 60.8 kB | 60.8 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | Skn0tt/next.js patch-1 | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31.1 kB | 31.1 kB | ✓ |
Overall change | 31.1 kB | 31.1 kB | ✓ |
Client Pages
vercel/next.js canary | Skn0tt/next.js patch-1 | Change | |
---|---|---|---|
_app-5cc66b2..6f03.js gzip | 1.3 kB | 1.3 kB | ✓ |
_error-55112..054d.js gzip | 3.68 kB | 3.68 kB | ✓ |
amp-89a5460c..567f.js gzip | 558 B | 558 B | ✓ |
hooks-8c2e74..be37.js gzip | 924 B | 924 B | ✓ |
index-fec729..83b2.js gzip | 243 B | 243 B | ✓ |
link-dd34d9b..0ade.js gzip | 1.66 kB | 1.66 kB | ✓ |
routerDirect..5759.js gzip | 336 B | 336 B | ✓ |
withRouter-1..98bf.js gzip | 334 B | 334 B | ✓ |
Overall change | 9.03 kB | 9.03 kB | ✓ |
Client Build Manifests
vercel/next.js canary | Skn0tt/next.js patch-1 | Change | |
---|---|---|---|
_buildManifest.js gzip | 349 B | 349 B | ✓ |
Overall change | 349 B | 349 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | Skn0tt/next.js patch-1 | Change | |
---|---|---|---|
index.html gzip | 610 B | 610 B | ✓ |
link.html gzip | 617 B | 617 B | ✓ |
withRouter.html gzip | 605 B | 605 B | ✓ |
Overall change | 1.83 kB | 1.83 kB | ✓ |
Serverless Mode (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | Skn0tt/next.js patch-1 | Change | |
---|---|---|---|
buildDuration | 17.4s | 15.9s | -1.5s |
nodeModulesSize | 46.7 MB | 46.7 MB |
Client Bundles (main, webpack, commons)
vercel/next.js canary | Skn0tt/next.js patch-1 | Change | |
---|---|---|---|
597-3f457946..288d.js gzip | 13.3 kB | 13.3 kB | ✓ |
778-6834d41c..48a9.js gzip | 7.05 kB | 7.05 kB | ✓ |
framework.HASH.js gzip | 39.3 kB | 39.3 kB | ✓ |
main-HASH.js gzip | 151 B | 151 B | ✓ |
webpack-HASH.js gzip | 993 B | 993 B | ✓ |
Overall change | 60.8 kB | 60.8 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | Skn0tt/next.js patch-1 | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31.1 kB | 31.1 kB | ✓ |
Overall change | 31.1 kB | 31.1 kB | ✓ |
Client Pages
vercel/next.js canary | Skn0tt/next.js patch-1 | Change | |
---|---|---|---|
_app-5cc66b2..6f03.js gzip | 1.3 kB | 1.3 kB | ✓ |
_error-55112..054d.js gzip | 3.68 kB | 3.68 kB | ✓ |
amp-89a5460c..567f.js gzip | 558 B | 558 B | ✓ |
hooks-8c2e74..be37.js gzip | 924 B | 924 B | ✓ |
index-fec729..83b2.js gzip | 243 B | 243 B | ✓ |
link-dd34d9b..0ade.js gzip | 1.66 kB | 1.66 kB | ✓ |
routerDirect..5759.js gzip | 336 B | 336 B | ✓ |
withRouter-1..98bf.js gzip | 334 B | 334 B | ✓ |
Overall change | 9.03 kB | 9.03 kB | ✓ |
Client Build Manifests
vercel/next.js canary | Skn0tt/next.js patch-1 | Change | |
---|---|---|---|
_buildManifest.js gzip | 349 B | 349 B | ✓ |
Overall change | 349 B | 349 B | ✓ |
Serverless bundles Overall increase ⚠️
vercel/next.js canary | Skn0tt/next.js patch-1 | Change | |
---|---|---|---|
_error.js | 1.35 MB | 1.35 MB | |
404.html | 2.76 kB | 2.76 kB | ✓ |
500.html | 2.75 kB | 2.75 kB | ✓ |
amp.amp.html | 10.7 kB | 10.7 kB | ✓ |
amp.html | 1.96 kB | 1.96 kB | ✓ |
hooks.html | 2.01 kB | 2.01 kB | ✓ |
index.js | 1.35 MB | 1.35 MB | |
link.js | 1.4 MB | 1.4 MB | |
routerDirect.js | 1.4 MB | 1.4 MB | |
withRouter.js | 1.4 MB | 1.4 MB | |
Overall change | 6.91 MB | 6.91 MB |
Webpack 5 Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary | Skn0tt/next.js patch-1 | Change | |
---|---|---|---|
buildDuration | 12.4s | 12.7s | |
nodeModulesSize | 46.7 MB | 46.7 MB |
Page Load Tests Overall decrease ⚠️
vercel/next.js canary | Skn0tt/next.js patch-1 | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.261 | 2.294 | |
/ avg req/sec | 1105.63 | 1089.63 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.112 | 1.161 | |
/error-in-render avg req/sec | 2248.26 | 2152.5 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | Skn0tt/next.js patch-1 | Change | |
---|---|---|---|
597-3f457946..288d.js gzip | 13.3 kB | 13.3 kB | ✓ |
778-6834d41c..48a9.js gzip | 7.05 kB | 7.05 kB | ✓ |
framework.HASH.js gzip | 39.3 kB | 39.3 kB | ✓ |
main-HASH.js gzip | 151 B | 151 B | ✓ |
webpack-HASH.js gzip | 993 B | 993 B | ✓ |
Overall change | 60.8 kB | 60.8 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | Skn0tt/next.js patch-1 | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31.1 kB | 31.1 kB | ✓ |
Overall change | 31.1 kB | 31.1 kB | ✓ |
Client Pages
vercel/next.js canary | Skn0tt/next.js patch-1 | Change | |
---|---|---|---|
_app-5cc66b2..6f03.js gzip | 1.3 kB | 1.3 kB | ✓ |
_error-55112..054d.js gzip | 3.68 kB | 3.68 kB | ✓ |
amp-89a5460c..567f.js gzip | 558 B | 558 B | ✓ |
hooks-8c2e74..be37.js gzip | 924 B | 924 B | ✓ |
index-fec729..83b2.js gzip | 243 B | 243 B | ✓ |
link-dd34d9b..0ade.js gzip | 1.66 kB | 1.66 kB | ✓ |
routerDirect..5759.js gzip | 336 B | 336 B | ✓ |
withRouter-1..98bf.js gzip | 334 B | 334 B | ✓ |
Overall change | 9.03 kB | 9.03 kB | ✓ |
Client Build Manifests
vercel/next.js canary | Skn0tt/next.js patch-1 | Change | |
---|---|---|---|
_buildManifest.js gzip | 349 B | 349 B | ✓ |
Overall change | 349 B | 349 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | Skn0tt/next.js patch-1 | Change | |
---|---|---|---|
index.html gzip | 610 B | 610 B | ✓ |
link.html gzip | 617 B | 617 B | ✓ |
withRouter.html gzip | 605 B | 605 B | ✓ |
Overall change | 1.83 kB | 1.83 kB | ✓ |
Diffs
Diff for index.html
@@ -48,7 +48,7 @@
"props": { "pageProps": {} },
"page": "/",
"query": {},
- "buildId": "AUTQttZNxUUmJwQ4PzaK_",
+ "buildId": "Iu19PHIGbHowJ8MotdiUd",
"isFallback": false,
"gip": true
}
@@ -86,11 +86,11 @@
async=""
></script>
<script
- src="/_next/static/AUTQttZNxUUmJwQ4PzaK_/_buildManifest.js"
+ src="/_next/static/Iu19PHIGbHowJ8MotdiUd/_buildManifest.js"
async=""
></script>
<script
- src="/_next/static/AUTQttZNxUUmJwQ4PzaK_/_ssgManifest.js"
+ src="/_next/static/Iu19PHIGbHowJ8MotdiUd/_ssgManifest.js"
async=""
></script>
</body>
Diff for link.html
@@ -53,7 +53,7 @@
"props": { "pageProps": {} },
"page": "/link",
"query": {},
- "buildId": "AUTQttZNxUUmJwQ4PzaK_",
+ "buildId": "Iu19PHIGbHowJ8MotdiUd",
"isFallback": false,
"gip": true
}
@@ -91,11 +91,11 @@
async=""
></script>
<script
- src="/_next/static/AUTQttZNxUUmJwQ4PzaK_/_buildManifest.js"
+ src="/_next/static/Iu19PHIGbHowJ8MotdiUd/_buildManifest.js"
async=""
></script>
<script
- src="/_next/static/AUTQttZNxUUmJwQ4PzaK_/_ssgManifest.js"
+ src="/_next/static/Iu19PHIGbHowJ8MotdiUd/_ssgManifest.js"
async=""
></script>
</body>
Diff for withRouter.html
@@ -48,7 +48,7 @@
"props": { "pageProps": {} },
"page": "/withRouter",
"query": {},
- "buildId": "AUTQttZNxUUmJwQ4PzaK_",
+ "buildId": "Iu19PHIGbHowJ8MotdiUd",
"isFallback": false,
"gip": true
}
@@ -86,11 +86,11 @@
async=""
></script>
<script
- src="/_next/static/AUTQttZNxUUmJwQ4PzaK_/_buildManifest.js"
+ src="/_next/static/Iu19PHIGbHowJ8MotdiUd/_buildManifest.js"
async=""
></script>
<script
- src="/_next/static/AUTQttZNxUUmJwQ4PzaK_/_ssgManifest.js"
+ src="/_next/static/Iu19PHIGbHowJ8MotdiUd/_ssgManifest.js"
async=""
></script>
</body>
# Conflicts: # packages/next/pages/_document.tsx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
Since
-1
is truthy, every JSON.stringify error is mistaken to becircular structure
. This commit fixes that behaviour, so that other errors likeDo not know how to serialize Bigint
(see blitz-js/babel-plugin-superjson-next#63) aren't swallowed.Bug
fixes #number
Feature
fixes #number
Documentation / Examples