prettier-atom icon indicating copy to clipboard operation
prettier-atom copied to clipboard

Atom Crashes When Trying to Save HTML Files

Open ghost opened this issue 5 years ago • 13 comments

I'm using Atom 1.34.0 on Windows 10 and I had configured Prettier to format on-save. It works fine on javascript files but when I try to save HTML files, it hangs and I have to force close the app.

I know that Prettier is the problem because once I disabled it, the HTML file saved no problem.

How can I go about fixing this? The package version of prettier-atom is 0.56.2

ghost avatar Jan 11 '19 03:01 ghost

How big is the HTML file you’re saving?

j-f1 avatar Jan 11 '19 10:01 j-f1

Also, can you confirm that this works fine outside of prettier-atom (using Pretter directly)?

robwise avatar Jan 11 '19 15:01 robwise

How big is the HTML file you’re saving?

It's only 34kb

ghost avatar Jan 14 '19 20:01 ghost

Also, can you confirm that this works fine outside of prettier-atom (using Pretter directly)?

I ran Prettier from the CLI and it worked perfectly.

ghost avatar Jan 14 '19 20:01 ghost

Same for me with a 28kB html. Prettier CLI works fine. I have disabled autoformat for *.html until this is fixed.

schteff avatar Jan 18 '19 12:01 schteff

Can someone give me some sample html and filename that fails for them and I can try to reproduce locally?

robwise avatar Jan 18 '19 13:01 robwise

I started out by modifying this template: https://onepagelove.com/evelyn

evelyn.zip test with the index.html

I have redone most of it on my own but I have never been able to format it with prettier in Atom. (prettier CLI works fine)

schteff avatar Jan 18 '19 14:01 schteff

I am experiencing this issue still with the following html file: index.html gist

davidmwhynot avatar Apr 19 '19 14:04 davidmwhynot

Can confirm. Tried saving a file with 200 lines of SVG inline and it consistently crashed my editor.

Benjamin-Lee avatar Jul 10 '19 23:07 Benjamin-Lee

Me too

miloxeon avatar Oct 25 '19 04:10 miloxeon

@uyouthe Can you provide a gist if possible? I'm not sure what the common thread here is, but it seems to be based on the actual code in the file and very rare. I want to see if there's something obvious about what's going on.

robwise avatar Oct 25 '19 17:10 robwise

@robwise https://miloslav.website, index.html

miloxeon avatar Oct 25 '19 17:10 miloxeon

Awesome, I think I've narrowed down the issue. When calling prettier.formatWithCursor, prettier has an out of memory error.

It is this old issue here: https://github.com/prettier/prettier/issues/4801

While we wait for Prettier to fix it, what I suggest you do is run prettier from the command line to format the file the first time. This uses the normal (as opposed to formatWithCursor) method so it shouldn't crash. From then on, the diff should be much more manageable for Prettier and you shouldn't have the issue again and you can just use prettier-atom as normal.

robwise avatar Oct 28 '19 17:10 robwise