var tmp = require('tmp');
var fs = require('fs');
tmp.dir({ template: '/tmp/tmp-XXXXXX', unsafeCleanup: true }, function _tempDirCreated(err, path) {
if (err) {
throw err;
}
fs.mkdirSync(path + '/child1');
fs.mkdirSync(path + '/child2');
});
It appears that the order that the directories are pushed on to the removal queue are unordered so when the top-level tmp directory is removed, child1/child2 directories still remain in the "to be removed" queue.
The tmp dir will not be cleaned up as there is an uncaught exception thrown when fs.rmdirSync(dir) tries to remove the directories that no longer exists.
To reproduce:
It appears that the order that the directories are pushed on to the removal queue are unordered so when the top-level tmp directory is removed, child1/child2 directories still remain in the "to be removed" queue.
The tmp dir will not be cleaned up as there is an uncaught exception thrown when fs.rmdirSync(dir) tries to remove the directories that no longer exists.