-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: get rid of rimraf package #27790
Conversation
This comment has been minimized.
This comment has been minimized.
adc3ceb
to
e4ee421
Compare
e4ee421
to
7ea070b
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Does it fix the bug? |
Yes see #27712 (comment) for investigation notes. rinraf was useful before Node.js had it built-in. |
This comment has been minimized.
This comment has been minimized.
@@ -245,7 +245,7 @@ export async function launchProcess(options: LaunchProcessOptions): Promise<Laun | |||
options.log(`[pid=${spawnedProcess.pid || 'N/A'}] starting temporary directories cleanup`); | |||
for (const dir of options.tempDirectories) { | |||
try { | |||
rimraf.sync(dir); | |||
fs.rmSync(dir, { force: true, recursive: true, maxRetries: 10 }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder how does the sync version retry? Perhaps we should limit the number of retries here, say to 5, because max total time is quadratic?
Signed-off-by: Max Schmitt <max@schmitt.mx>
Signed-off-by: Max Schmitt <max@schmitt.mx>
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Max Schmitt <max@schmitt.mx>
This comment has been minimized.
This comment has been minimized.
Test results for "tests 1"1 failed 8 flaky25986 passed, 604 skipped Merge workflow run. |
This seems more reliable nowadays as rimraf. microsoft#27712 --------- Signed-off-by: Max Schmitt <max@schmitt.mx>
export async function removeFolders(dirs: string[]): Promise<Error[]> { | ||
return await Promise.all(dirs.map((dir: string) => | ||
fs.promises.rm(dir, { recursive: true, force: true, maxRetries: 10 }) | ||
)).catch(e => e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a mistake of .catch(e => e)));
, i.e. should catch each error of fs.promises.rm
. Otherwise the return type should be Promise<Error>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const fs = require('fs');
const dirs = ['/tmp/x', '/tmp/y'];
(async () => {
await Promise.all(dirs.map((dir) => Promise.reject({ dir }))).catch(e => e).then(x => console.log(x));
// { dir: '/tmp/x' }
await Promise.all(dirs.map((dir) => Promise.reject({ dir }).catch(e => e))).then(x => console.log(x));
// [ { dir: '/tmp/x' }, { dir: '/tmp/y' } ]
})();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a result, the following line of packages/playwright/src/runner/tasks.ts
yields TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator))
.
await Promise.all(Array.from(outputDirs).map(outputDir => removeFolders([outputDir]).then(async ([error]) => {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, are you interested in contributing a fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes of course, I opened a pull request: #28239.
This PR fixes microsoft#27790 (review). Previously this function returns only the first error when some of the promises fail. But the type annotation suggests that the original intention was to collect all the errors. This commit fixes the error values, and unexpected `TypeError: object is not iterable`.
This seems more reliable nowadays as rimraf.
#27712