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

Update locking test #72

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

quarenw
Copy link
Contributor

@quarenw quarenw commented Jun 16, 2022

This PR is to hopefully fix some strange errors with the test for locking to prevent multiple parallel installations.

I have not been able to replicate the issue consistently but from what I saw during debugging the issue the test would sometimes not throw an error due to an absence of a lock file.

My hunch is that as there is no way to guarantee promises run in parallel sometimes the installation of the local plugin1 happens all at once in the await and so never conflicting with the "moment" plugin install.

This change makes it so both installs are in theory initiated at once and given that the moment install is more likely to yield in the event loop, more likely to then clash as the local plugin install starts.

@quarenw quarenw mentioned this pull request Jun 16, 2022
Copy link
Owner

@davideicardi davideicardi left a comment

Choose a reason for hiding this comment

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

Nice! Thank you!

} catch (err) {
await installation1;
return;
await Promise.all([ installation1, installation2 ]);
Copy link
Owner

Choose a reason for hiding this comment

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

I see that with this change the next test fails. Maybe because one of these promise is not yet completed?
A possible solution can be to use Promise.allSettled instead of Promise.all?
So that we are sure that all installation are completed and there aren't any pending installation.
What do you think?

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled

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.

2 participants