-
Notifications
You must be signed in to change notification settings - Fork 907
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: Workaround JSON.stringify failing on large arrays with the error… #2051
fix: Workaround JSON.stringify failing on large arrays with the error… #2051
Conversation
|
||
// Convert to JSON in chunks because JSON.stringify() will fail for large | ||
// arrays with the error "RangeError: Invalid string length" | ||
const out = events.map(JSON.stringify).join(","); |
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 we keep the space of 4 as in the original code?
fs.writeFileSync( | ||
transformedFilePath, | ||
JSON.stringify(events, undefined, 4), | ||
"["+out+"]", |
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.
please run yarn lint --fix
to fix formatting
Thank you for contributing a fix. Small adjustments and I think we're good to merge it |
Hey @paddlefish, thanks for creating PR! If you don't have time for adjusting PR with @thymikee's suggestions - could you please allow edits from maintainers so that I can finish this PR, and we can get this merged? |
Previously it could fail with the error "RangeError: Invalid string length" when downloading profiling Fixes react-native-community#2050
1427136
to
54ad45b
Compare
Hi Szymon -- thanks for tagging me. I missed the original feedback. I had trouble running I also added a helper function to keep it at 4-spaces. There are some other subtle differences in the format of the file (the new algorithm doesn't insert as many new lines as JSON.stringify does). I assumed this didn't matter --it's valid JSON either way. e.g. JSON.stringify
The new algorithm
|
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.
Thank you!
CI Green, @thymikee ready to merge. |
…geError: Invalid string length" when downloading profiling
Summary:
Fixes #2050
Test Plan:
Follow steps in issue 2050
Checklist