-
Notifications
You must be signed in to change notification settings - Fork 73
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
Changed trim stats to stream and added test #615
Changed trim stats to stream and added test #615
Conversation
AP-1905 Turbosnap breaks with large stats file
Proposed solution in comments is to stream JSON in the Original title: Investigate modifying the way we read the stats file in the monday.com is experiencing an issue where TurboSnap fails because their stats file is too large Here is the CLI output that they sent me
Specifically, this line Upon further research, I discovered that their stats file is 523 MB, which is larger than the 512 MB maximum for the string data type I had Tom Bogin, from Monday, attempt to run the Tom proposed that maybe we could make the trim stats file stream the JSON like SB does when it writes it in the first place? @ghengeveld What do you think about this? Our stats file, for comparison, is only about 77 MB Monday's stat file is really large and I'm not convinced that there isn't a configuration issue on their end Possible Investigative RoutesHowever, I do think that it would be worth looking into if we can stream the JSON via the trim stats file process Alternatively, we could trim the stats file when we build Storybook and be proactive about it |
…ap-1905-turbosnap-breaks-with-large-stats-file
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.
Awesome! LGTM @ethriel3695
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.
Nice, I like it!
Context
This PR aims to address the issue that we are seeing for some of our customers, where the Webpack preview stats file is too large to parse through for the TurboSnap process.
In Storybook, we already write a stream for the stats file so it makes sense that we could read a stream and get the file contents accordingly.
Here is the file reference in Storybook
https://github.com/storybookjs/storybook/blob/next/code/lib/core-server/src/utils/output-stats.ts
Changes
I added a function to process the reading of the stats file so I could add a test for that functionality
Added a jest test to verify that the
readStatsFile
function is returning an Array of objects as expected with anid
property.Added a new library that we also use in Storybook
https://github.com/discoveryjs/json-ext#stringifystreamvalue-replacer-space
Testing
npx chromatic trim-stats-file
on my branch and saved the file locally in a different locationyarn
to update dependenciesnpx chromatic trim-stats-file
again and compared the file with the other file I had saved locally and which was built and trimmed off my branch.The image shows an exact match other than white space
![Screen Shot 2022-07-27 at 9 30 27 PM](https://user-images.githubusercontent.com/12070791/181414338-af91a298-7c05-4ef9-8d7f-99980a97e64c.png)