Hi,
I love this package but I have an annoying issue with "big files", ie more than 200 lines
Everytime I update something and I save the file --> atom is crashing.
Sometimes it's only freezing but I need to wait more than 30seconds [ too much ].
Most of the time Atom is when I'm commented something.
Thanks,
Hi there!
Could you provide an example of a file that causes Atom to crash as well as your current package list?
$ apm list --installed --bare
Sure,
This is my package list:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
I can't provide a full example of my code but you can see the structure here
are you able to reproduce with "a big file" and post the contents of that? We're mainly looking for ways to reproduce and understand your issue. I've used the prettier plugin on many files larger than 200 lines, and I doubt it's a hardware issue as 200 is just not that much.
Hi @olsonpm,
I reproduce the issue, it's not about the size of the file, I think it's something else;
You can find here another gist with less than 120 lines.
The crash happen when I comment any import line on the top of the file and I save the file.
I also don't think it's an hardware issue.
Thanks :)
haha what a weird bug. I'm able to reproduce. I'll let you know what I find and thanks for taking the time to get reproduceable steps!
You're welcome :-D
I'll try to find how to fix-it too.
wow this was frustrating. I don't know what's going on but updating the prettier version fixes it.
@robwise @SavePointSam, unless either of you want to take a deeper look, does it sound okay to update the bundled prettier version and advise users to update their prettier version locally if they come across this bug?
Some debugging notes for reference:
1.10.2 -> 1.11.1. I didn't dig into the changes to understand it further.// src/main/ast-to-doc.js
const comments = require("./comments");
const FastPath = require("../common/fast-path");
const multiparser = require("./multiparser");
-const util = require("../common/util");
const doc = require("../doc");
const docBuilders = doc.builders;
@@ -75,7 +74,10 @@ function genericPrint(path, options, printPath, args) {
// Escape hatch
if (printer.hasPrettierIgnore && printer.hasPrettierIgnore(path)) {
- return options.originalText.slice(util.locStart(node), util.locEnd(node));
+ return options.originalText.slice(
+ options.locStart(node),
+ options.locEnd(node)
+ );
}
if (node) {
@majdi - a workaround for now would be to install the latest prettier local to your project. Then the plugin will take that version instead of:
Have you tried passing in a different AST parser when calling the CLI from our end? We may be providing an incorrect parser for the file type. Can you look into that as a potential solution, @olsonpm?
I personally don't mind updating our bundled Prettier, but we should probably explore other potential solutions to figure out if we really are the problem first, even more so because there is no mention in the release notes about this problem. Did you look in the Prettier issues for something related?
i just pasted his code into a brand new js file so unless i've always been passing an incorrect parser i doubt that's the issue. I also didn't check this on a clean install, so it's possible package conflicts are at play. However given the delay happens at that one recursive call and prettier fails to throw an error, I think there's something else is going on.
Honestly I've sunk as much time into this issue as I care to as well. This was making my atom crash at times and so the debugging experience wasn't great. I'm not going to debug further.
I'll bump now and we can see if it solves the issue, it never hurts to bump it anyway.
it solved the issue for me locally inside atom --dev with prettier atom dev linked. You're right OP should verify the fix though :)
thanks robwise
I just install locally prettier@^1.11.1 and it works well. Thanks @olsonpm!
Hope you'll find the origin of this weird bug 馃
Okay bumped to prettier 1.11.1 in prettier-atom 0.52.0
I've given up actually haha. I've got some problems that are more interesting atm and bumping a version is a good'nuff stopping point for me.
@majdi If you have a moment please try the new version of prettier-atom to make sure it solves your problem. If it does then go ahead and close the issue.
Perfect @olsonpm it works in both cases. Thanks guy 馃憤
Hey, this still happens for me on the latest version of the plugin
Did you have the same issue than me? I didn't have any problem still the update.
@joarwilk, see what version of prettier is installed in your node_modules. Even if you don't install prettier as a dependency, if one is installed indirectly (via another dependency) then the plugin picks that one up.
Went away after a fresh computer restart. Probably some spooky cache still giving me the previous version after updating. Works just fine now!
FYI: Still crashes on large Copy&Paste and save in .vue File.
If I use only half the data, it works fine.
Atom: 1.44.0 x64 (OSX)
Prettier-Atom: 0.58.2
Most helpful comment
I just install locally prettier@^1.11.1 and it works well. Thanks @olsonpm!
Hope you'll find the origin of this weird bug 馃