-
Notifications
You must be signed in to change notification settings - Fork 161
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
npm cache clean doesn't clean hard-source cache #257
Comments
I get the issue even if I clean the folder with rimraf before build. Although not all the times. Every now and then the build succeeds. Mostly failing though. |
Cache renaming happens when the cache compacts itself. This is probably a timing issue while compacting. Renaming the smaller cache copy may be happening too soon after deleting the larger original cache. The cache has to write all the built modules to disk the first time webpack builds for a new cache. That time serializing and writing everything is a portion of the extra time HardSource uses on the first build. Following builds only write changes greatly reducing the time needed to write out to disk. To keep the cache from growing too large, it'll compact the cache once it reaches a certain size larger than the cache needs. It writes a second copy of the cache without the old entries, removes the old cache and renames the new copy to the old copies position. |
It'd be cool to be able to use I guess we could add a hard-source helper binary. That'd be great to clean the cache or get a list of caches, delete caches by date (like caches older than a week or two), or stats or something. I'm not sure how to highlight that tool though to help in situations like this. |
Oh, to be clear I'll add a small timeout between the cache delete and rename during compacting in a patch release. Thanks @JGJP for opening the issue and @JonWallsten for the additional info. |
@JonWallsten's added info in #260 makes it clear to me that the more likely culprit is the atomic json write in the cache behaviour. To echo #260 (comment), I'll add some retry behaviour and soft failure if it keeps happening so at least webpack can finish. |
@JGJP @JonWallsten if you have any thoughts on a hard-source helper binary for clearing the cache, etc. I'd really appreciate y'all sharing those with me. |
@mzgoddard I don't mind having to clean it manually. I do it as a precaution before I start a new build, or the watch, to make sure I start with a clean slate. I'm cleaning other stuff as well, so it's no extra work. Besides, there are no "standard" cleaning command to connect it to anyways, right? |
@mzgoddard Thanks for your replies. I don't think I have the expertise to comment on making a binary, I'll probably just end up running a Powershell function to delete the cache before crucial builds just in case. |
@JGJP Use the rimraf package, then you can add it as a script in your package.json. |
@JGJP I mean binary like the |
Oh ok I get it now, thanks! |
I've been getting some errors that look like
EPERM: cannot rename cache/hard-source/somefile
when I try to build. It's a problem with the cache, but runningnpm cache clean
doesn't deletenode_modules\.cache\hard-source
. The problem is resolved when I delete this folder manually, but it would be nice if we could clear it withnpm cache clean
, especially for my junior devs.The text was updated successfully, but these errors were encountered: