You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] /tmp/npm-${PID}-* directories should be cleaned when "npm pack" gets terminated #695
"npm pack" call produces junk data in the system temp (smth like /tmp/npm-8452-4aa95566). This useless data quickly populates the /tmp and puts responsibility on npm users to clean it. I think the responsibility to remove this data should be on npm code, because npm code produces there intermediate directories. I think it is not a big deal to add a removal upon exiting of the npm process.
UPDATE: I am talking about the case "npm pack" failed and did not clean the folder. There should be some error handling added so that npm cleans the temp folder before gets abnormally terminated.
I assume that the place where this path is evaluated is probably ./lib/npm.js, thus probably the removal can be added to this script:
Object.defineProperty(npm, 'tmp',
{
get: function () {
if (!tmpFolder) tmpFolder = 'npm-' + process.pid + '-' + rand
return path.resolve(npm.config.get('tmp'), tmpFolder)
},
enumerable: true
})
changed the title [-][BUG] /tmp/npm-${PID}-* directories should be cleaned[/-][+][BUG] /tmp/npm-${PID}-* directories should be cleaned when "npm pack" gets terminated[/+]on Jan 16, 2020
@ljharb, even if we assume that we both agree with your general formulation the fact is that npm already cleans these temp directories if it successfully exits and in this case the remaining directories have size 1Mb which is fully aceptable for me, because can be cleaned afterwards by the OS as you said:
$ du -ms /tmp/npm-*
1 /tmp/npm-19300-5dc16931
1 /tmp/npm-27233-198faf4e
1 /tmp/npm-27893-20fd4542
1 /tmp/npm-27919-5a5102a4
...
The problem is that the removal is not called in some error cases and then these directories contain large binary data. That is, my request is not about adding of a new feature, but about the improving/fixing of the existing feature.
About the "typically" I would argue about that. From my point of view the remaining intermediate data looks like a memory leak or like a file descriptor which remains open()ed after the program exiting. Many applications write files to /tmp and remove them without delegating it to the OS.
Just imagine that we run not only npm cli on a build server, but a lot of other builds which create a remove tones of data in /tmp in parallel. If all this software had not cleaned their temp data then even the daily clean of /tmp would have not been sufficient. Total explicit cleaning of /tmp is also a bad solution, because in this case you must clearly define the time when no build process is running on the build server, otherwise you make the jobs which are currently using /tmp to fail etc.
But as I already said npm does clean, but sometimes terminates without doing this. I think fixing of this would be a good improvement.
npm v6 is no longer in active development; We will continue to push security releases to v6 at our team's discretion as-per our Support Policy.
If your bug is preproducible on v7, please re-file this issue using our new issue template.
If your issue was a feature request, please consider opening a new RRFC or RFC. If your issue was a question or other idea that was not CLI-specific, consider opening a discussion on our feedback repo
Activity
[-][BUG] /tmp/npm-${PID}-* directories should be cleaned[/-][+][BUG] /tmp/npm-${PID}-* directories should be cleaned when "npm pack" gets terminated[/+]ljharb commentedon Jan 16, 2020
Typically it’s the OS’s job to clean up the temp dir, not the user’s nor applications’. That’s it’s purpose.
AlexanderSamoilov commentedon Jan 17, 2020
@ljharb, even if we assume that we both agree with your general formulation the fact is that npm already cleans these temp directories if it successfully exits and in this case the remaining directories have size 1Mb which is fully aceptable for me, because can be cleaned afterwards by the OS as you said:
$ du -ms /tmp/npm-*
1 /tmp/npm-19300-5dc16931
1 /tmp/npm-27233-198faf4e
1 /tmp/npm-27893-20fd4542
1 /tmp/npm-27919-5a5102a4
...
The problem is that the removal is not called in some error cases and then these directories contain large binary data. That is, my request is not about adding of a new feature, but about the improving/fixing of the existing feature.
About the "typically" I would argue about that. From my point of view the remaining intermediate data looks like a memory leak or like a file descriptor which remains open()ed after the program exiting. Many applications write files to /tmp and remove them without delegating it to the OS.
Just imagine that we run not only npm cli on a build server, but a lot of other builds which create a remove tones of data in /tmp in parallel. If all this software had not cleaned their temp data then even the daily clean of /tmp would have not been sufficient. Total explicit cleaning of /tmp is also a bad solution, because in this case you must clearly define the time when no build process is running on the build server, otherwise you make the jobs which are currently using /tmp to fail etc.
But as I already said npm does clean, but sometimes terminates without doing this. I think fixing of this would be a good improvement.
darcyclarke commentedon Jun 2, 2021
npm
v6is no longer in active development; We will continue to push security releases tov6at our team's discretion as-per our Support Policy.If your bug is preproducible on
v7, please re-file this issue using our new issue template.If your issue was a feature request, please consider opening a new RRFC or RFC. If your issue was a question or other idea that was not CLI-specific, consider opening a discussion on our feedback repo
Closing: This is an automated message.