Skip to content

Commit 19d1980

Browse files
authored
perf: avoid fsp.unlink if we don't use the promise (#12589)
1 parent 4215e22 commit 19d1980

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

packages/vite/src/node/config.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,11 +1093,7 @@ async function loadConfigFromBundledFile(
10931093
try {
10941094
return (await dynamicImport(fileUrl)).default
10951095
} finally {
1096-
try {
1097-
await fsp.unlink(fileNameTmp)
1098-
} catch {
1099-
// already removed if this function is called twice simultaneously
1100-
}
1096+
fs.unlink(fileNameTmp, () => {}) // Ignore errors
11011097
}
11021098
}
11031099
// for cjs, we can register a custom loader via `_require.extensions`

packages/vite/src/node/optimizer/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ export function runOptimizeDeps(
626626

627627
// Clean up old files in the background
628628
for (const filePath of oldFilesPaths)
629-
if (!newFilesPaths.has(filePath)) fsp.unlink(filePath)
629+
if (!newFilesPaths.has(filePath)) fs.unlink(filePath, () => {}) // ignore errors
630630

631631
await Promise.all(files)
632632
},

0 commit comments

Comments
 (0)