Skip to content

Commit 1795f95

Browse files
committedMar 5, 2025
Use fs.rm() over deprecated rmdir() for recursive cleanup
1 parent efd5095 commit 1795f95

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed
 

‎lib/tmp.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,9 @@ async function withSubdir(prefix, fn, options) {
706706
...(options && options.logTags ? options.logTags : {}),
707707
path: tmpDir
708708
};
709+
710+
// Note: we're currently only deleting the leaf (where all files will be
711+
// created); the current version may leave empty directories in place.
709712
_logger.debug(logTags, "Create temp dir");
710713
await fsp.mkdir(tmpDir, { recursive: true });
711714

@@ -714,7 +717,7 @@ async function withSubdir(prefix, fn, options) {
714717
_logger.info(logTags,"lib-tmp.gc.start");
715718
const t0 = Date.now();
716719
try {
717-
await fsp.rmdir(tmpDir, { recursive: true, maxRetries: 5 });
720+
await fsp.rm(tmpDir, { recursive: true, maxRetries: 5 });
718721
_logger.info({ ...logTags, duration: Date.now() - t0 }, "lib-tmp.gc.end");
719722
} catch (error) {
720723
_logger.info({ ...logTags, duration: Date.now() - t0, error }, "lib-tmp.gc.error");

0 commit comments

Comments
 (0)