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: make cleanup async #1156

Merged
merged 7 commits into from
May 12, 2020
Merged

Conversation

molant
Copy link
Contributor

@molant molant commented May 7, 2020

Summary:

I'm trying to improve the reliability of Windows CI so I can get #1109 green.
I've found out that cleanup() uses rimraf.sync underneath. Windows FS is not very... reliable, and sometimes you can end up with ENOTEMPTY errors like this one. In fact, rimraf's documentation calls that out:

Windows: EBUSY and ENOTEMPTY - rimraf will back off a maximum of opts.maxBusyTries times before giving up, adding 100ms of wait between each attempt. The default maxBusyTries is 3.

The problem is the above does not apply when using the sync method:

If an EBUSY, ENOTEMPTY, or EPERM error code is encountered on Windows systems, then rimraf will retry with a linear backoff wait of 100ms longer on each try. The default maxBusyTries is 3.
Only relevant for async usage.

I've changed it to use the async version and updated the tests. Hopefully that should make Windows more reliable.

Test Plan:

CI

@thymikee
Copy link
Member

thymikee commented May 7, 2020

Weirdly Windows e2e tests started to time out with 5s now. Even though we set the timeout separately for these tests. Looks like misconfiguration from our side, or a Jest bug.

@molant
Copy link
Contributor Author

molant commented May 7, 2020

@thymikee locally I'm having different issues with e2e tests. I've opened #1157

@molant molant force-pushed the fix/enotempty branch 4 times, most recently from 7bb398c to 1a0b9bb Compare May 7, 2020 14:25
@molant
Copy link
Contributor Author

molant commented May 7, 2020

@thymikee this is green now. I had to make the cleanup synchronous in the e2e tests to not timeout 🤯
It might be that the before/after hooks are not finishing correctly in there when running asynchronously. I tried to debug a bit but you mentioned that some tests are going away and some others seemed to execute non windows paths so it was a bit too confusing.

Hopefully this is good enough, can get merged, and Windows is more reliable from now on 😊

jest/helpers.ts Outdated
@@ -77,7 +80,13 @@ export const makeTemplate = (
return values[number - 1];
});

export const cleanup = (directory: string) => rimraf.sync(directory);
export const cleanup = (directory: string, async = true) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have 2 functions named: cleanupSync and cleanup. Passing a boolean as a function parameter is a code-smell.

@thymikee thymikee requested a review from Esemesek May 8, 2020 14:57
molant added 4 commits May 8, 2020 07:58
Using `rimraf.sync` can cause `ENOTEMPTY` and `EBUSY` errors on Windows.
This can make the Windows CI to fail randomly. Changing to the async
method defaults to autoretry 3 times and thus avoiding this issues.
jest/setupE2eTests.js Outdated Show resolved Hide resolved
__e2e__/default.test.ts Outdated Show resolved Hide resolved
__e2e__/default.test.ts Outdated Show resolved Hide resolved
@thymikee thymikee dismissed Esemesek’s stale review May 8, 2020 16:13

feedback addressed

@thymikee thymikee merged commit 5819a17 into react-native-community:master May 12, 2020
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.

3 participants