-
-
Notifications
You must be signed in to change notification settings - Fork 945
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
Use write-file-atomic for writing fixed styles to filesystem #2992
Conversation
Huh, looks I spoke too soon - this small change causes Stylelint to use a lot more memory than before, at least when running tests. On my laptop master uses ~450MB, while on this branch it ballooned to 1.4GB then crashed with an out of memory error 😱 I'm not entirely sure what is happening here, so I'll try to dig deeper. |
So... erm, it seems that the culprit is I guess we could fork |
Okay, yes, I can verify that a simple Using the
|
FYI, we had a memory leak with |
@jeddy3 I believe this PR is ready for review |
dd4f1b4
to
b0d0f1b
Compare
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.
@ZhangYiJiang Sorry about the delay getting to this. LGTM!
Linking to isaacs/node-graceful-fs#102 for if/when the issue is resolved |
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.
LGTM
Once again, thanks @ZhangYiJiang, sorry it took us so long to merge 😄 |
Fixes #2991
This makes writing back the linted results when
--fix
is used atomic - previously if the operation was cancelled or crashed while the styles were been written, the sources could be left in an inconsistent state.The correct way to write file is to write it to a temp file first, then replace the original. As it turns out the nice folks at npm has written a package to do just that, and hey, if it's good enough for npm then it's probably good enough for Stylelint 😉