Skip to content
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

Merged
merged 4 commits into from
Oct 26, 2023
Merged

Conversation

mxschmitt
Copy link
Member

@mxschmitt mxschmitt commented Oct 25, 2023

This seems more reliable nowadays as rimraf.

#27712

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@mxschmitt mxschmitt marked this pull request as ready for review October 25, 2023 10:33
@github-actions

This comment has been minimized.

@pavelfeldman
Copy link
Member

Does it fix the bug?

@mxschmitt
Copy link
Member Author

Does it fix the bug?

Yes see #27712 (comment) for investigation notes. rinraf was useful before Node.js had it built-in.

@github-actions

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 });
Copy link
Contributor

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>
@github-actions

This comment has been minimized.

Signed-off-by: Max Schmitt <max@schmitt.mx>
@mxschmitt mxschmitt merged commit 5f36608 into microsoft:main Oct 26, 2023
8 checks passed
@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

Test results for "tests 1"

1 failed
❌ [playwright-test] › runner.spec.ts:118:5 › should ignore subprocess creation error because of SIGINT

8 flaky ⚠️ [chromium] › page/page-event-request.spec.ts:101:3 › should report navigation requests and responses handled by service worker
⚠️ [chromium] › library/tracing.spec.ts:239:5 › should not include trace resources from the previous chunks
⚠️ [chromium] › library/tracing.spec.ts:239:5 › should not include trace resources from the previous chunks
⚠️ [chromium] › page/page-event-request.spec.ts:101:3 › should report navigation requests and responses handled by service worker
⚠️ [firefox] › library/tracing.spec.ts:239:5 › should not include trace resources from the previous chunks
⚠️ [playwright-test] › ui-mode-test-ct.spec.ts:113:5 › should run component tests after editing test and component
⚠️ [webkit] › library/browsercontext-reuse.spec.ts:50:1 › should reset serviceworker
⚠️ [webkit] › library/tracing.spec.ts:239:5 › should not include trace resources from the previous chunks

25986 passed, 604 skipped
✔️✔️✔️

Merge workflow run.

Germandrummer92 pushed a commit to OctoMind-dev/playwright that referenced this pull request Oct 27, 2023
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);
Copy link
Contributor

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>.

Copy link
Contributor

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' } ]
})();

Copy link
Contributor

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]) => {

Copy link
Member Author

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?

Copy link
Contributor

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.

mxschmitt pushed a commit to mxschmitt/playwright that referenced this pull request Nov 20, 2023
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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants