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

Ensure we only have one git processing running in parallel #16

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andersekdahl
Copy link
Contributor

This adds a mutex to ensure that we don't run multiple git commands in parallel. Running multiple git commands in parallel is fine on most machines and OSes, but I recently had really wierd issues when trying to do so with the Node Alpine docker image. Git would respond, but not with the correct data. Once I ensured that we only called version.getCurrentVersion() once at a time the issue went away.

So this PR makes sure that we're "safe by defaut". It does mean that if you query git a lot it's going to be slightly slower because we no longer do it in parallel but I don't think that matters as I don't know of any use case where we'd want to call git in parallel like that.

src/git.ts Outdated
return result.stdout.trim();
async function git(args: string[], cwd: string | undefined) {
if (currentCommand) {
await currentCommand;
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't this just allow the first git command to be run separately, and then the rest all at once? 🤔 Or at least all the ones that were called before the first currentCommand has resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's very true! Nice catch, brain fart from me there. 😄 Fixed now!

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

2 participants