-
Notifications
You must be signed in to change notification settings - Fork 27.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: show large data warning once per page on prod (#46323)
<!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: --> ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [x] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Related * Closes #39146 - PR abandoned. ## Details I was having the same issue at work, as a workaround, we've changed the `largePageDataBytes` setting as advised but we'd like to keep the warning ideally. It's something we need to address, but just don't want to spam our log aggregators while the large data issue isn't resolved. I believe I've more or less copied what was in the original PR, some small differences: * I use `Set` instead of `Map`, please let me know if there is an advantage to using Map! * Just to keep code a bit tidier (subjective) put an early return instead of nesting all the code in an if. * Added a test to verify only one log appears even when the page is accessed twice [as requested here](#39146 (review)).
- Loading branch information
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react' | ||
import Link from 'next/link' | ||
|
||
export function getServerSideProps() { | ||
return { | ||
props: { | ||
lotsOfData: new Array(256 * 1000).fill('a').join(''), | ||
}, | ||
} | ||
} | ||
|
||
export default (props) => { | ||
return ( | ||
<> | ||
<p>lots of data returned</p> | ||
<Link href="/" id="home"> | ||
to home | ||
</Link> | ||
<br /> | ||
<Link href="/another" id="another"> | ||
to another | ||
</Link> | ||
</> | ||
) | ||
} |