-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Prettier crashes on formating large files #5004
Comments
It looks like your computer might be running out of memory- see this line:
I'm not saying we couldn't improve this, but as a workaround, you could try formatting the file on a box with more memory. |
Same problem for me with a ca. 20Mb file that exports a large array of json objects. I wanted to use this for mocking external data. Memory seems not to be the problem. When prettier crashed I still have 6GB of memory left.
|
@mkreim can you create reproducible test repo? |
@evilebottnawi I will ask, if I am allowed to do this. In principle its is one 20Mb file, but it contains data from a customer device. |
@mkreim maybe you can create fake data in same format? |
@suchipi Thanks a lot. That actually worked for me: $ /usr/bin/time --verbose yarn spsprettier
yarn run v1.12.3
$ NODE_OPTIONS=--max_old_space_size=4096 prettier --single-quote --trailing-comma es5 --print-width 100 --write src/spsSampleData_2.js
src/spsSampleData_2.js 26485ms
Done in 27.00s.
Command being timed: "yarn spsprettier"
User time (seconds): 41.90
System time (seconds): 2.03
Percent of CPU this job got: 161%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:27.22
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 2966620
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 848333
Voluntary context switches: 51786
Involuntary context switches: 6432
Swaps: 0
File system inputs: 0
File system outputs: 16
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0 |
I fear the data format is the problem they may be suspicious that someone may get something out of the keys in there. In principle its an array with ca. 10000 entries, where each entry is an Object with around 90 keys. While the values are numbers or short strings. Similar like this: export default [
{
key1: 0.1,
// until
key86: "blabla"
},
// repeat 10000 times
] In the original all code is in one line (output from JSON.stringify) |
@mkreim Such an array of objects sounds pretty easy to generate? |
Can be reproduced with Unity's demo of ASM.js
|
For a passable alternative, BeatifulSoup's |
I see a similar error when using Node 16. Switching to Node 14 runs prettier without an issue. Unfortunately, I can't share a link to the repo because it's private. |
I keep hitting this issue with my large files. Do you have a target date for fixing this? |
allocations.json is 137MB. I tried he NODE_OPTIONS environment variable that @trzecieu mentioned:
Node memory peaked at 16.42 GB, then crashed:
Anything larger gave me a
Any other workaround suggestions are welcome. |
This works for me: |
Hi!
I'm working with large ASM.js files generated by Emscripten, when I debug those I use tools like Prettier to make code at lease a little bit more readable.
In case of prettier I'm getting:
The text was updated successfully, but these errors were encountered: