vordgi / nimpl-classnames-minifier

Library for configuring style (css/scss/sass) modules to generate compressed classes in next.js
https://www.npmjs.com/package/@nimpl/classnames-minifier
MIT License
32 stars 1 forks source link

Error on build #70

Closed vitaliemiron closed 2 weeks ago

vitaliemiron commented 7 months ago

On build I have this error:

17:44:29 #12 0.774 Error: EBUSY: resource busy or locked, rmdir '/app/.next/cache' 17:44:29 #12 0.774 at rmdirSync (node:fs:1229:10) 17:44:29 #12 0.774 at _rmdirSync (node:internal/fs/rimraf:235:5) 17:44:29 #12 0.774 at rimrafSync (node:internal/fs/rimraf:193:7) 17:44:29 #12 0.774 at node:internal/fs/rimraf:253:9 17:44:29 #12 0.774 at Array.forEach () 17:44:29 #12 0.774 at _rmdirSync (node:internal/fs/rimraf:250:7) 17:44:29 #12 0.774 at rimrafSync (node:internal/fs/rimraf:193:7) 17:44:29 #12 0.774 at Object.rmSync (node:fs:1278:10) 17:44:29 #12 0.774 at validateDist (/app/node_modules/classnames-minifier/dist/lib/validateDist.js:44:22) 17:44:29 #12 0.774 at new ClassnamesMinifier (/app/node_modules/classnames-minifier/dist/ClassnamesMinifier.js:14:40) { 17:44:29 #12 0.774 errno: -16, 17:44:29 #12 0.774 syscall: 'rmdir', 17:44:29 #12 0.774 code: 'EBUSY', 17:44:29 #12 0.774 path: '/app/.next/cache' 17:44:29 #12 0.774 }

Why does it try to remove .next/cache?

vordgi commented 7 months ago

Next.js has a very complex caching system. It caches processed files and doesn't rebuild them during next builds, but takes them from the cache. However, when the package config changes - all these files need to be rebuilt. Without this, there will be critically many artifacts at the intersection of names or unexpected use of previous names.


vitaliemiron commented 6 months ago

Hey @vordgi, the problem was that we are using the docker container for deployment.

In that strategy, the .cache directory can't be deleted;

I fixed it in my fork

vordgi commented 6 months ago

It's very interesting that you can't delete the cache directory specifically. Inside this directory, for example, the cache/ncm directory (and no problem with this one).

Overall, do you really need caching in this file, do you reuse it between deployments?

I will add a disableDistDeletion option today, which will disable automatic deletion. Maybe this is what you need.

In any case, thank you for the task and solution.

I will research why exactly this directory is blocked. For now, let your task remain in case of similar problems.

vitaliemiron commented 6 months ago

sure, thanks @vordgi

you can test by deploy any next.js app with https://www.flightcontrol.dev