You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe that the readFile call is invoked and then the gitutil.pendingChangesExist() call is made right after. Both calls have asynchronous behavior, which introduces a race condition. I believe that this race condition is to blame for the random build failures.
Looking around the file, there is at least another case of this pattern. There might be more in the module if this is a general oversight by the author.
My suggestion is, given the generator/yield approach of the module, the workflow should be adapted to that or, for a smaller refactoring, the code should use fs.readFileSync instead. In the latter case, refactoring the code should be trivial. I could create a PR for that if there is consensus about the change.
The text was updated successfully, but these errors were encountered:
I find your analysis to be very plausible after a quick glance over the code. Given that there's already more sync stuff happening than async in this particular module (all the shelljs stuff is sync too), I would not object a fix that simply uses fs.readFileSync. An easy fix might be a good start anyway, so we can verify the fix in "production". But if you'd like to do a nice async version of this, I think nobody will be stopping you. Any PRs welcome!
I particularly like that someone already found the error but chose to ignore it 😅
Performing the read asynchronously introduces a race condition that can
cause the changes to not have been made yet
when they are checked by git.
This issue introduces random nightly build failures.
Fixes#195
I talked about this on Slack. The nightly build are sometimes broken.
I believe that the
readFile
call is invoked and then thegitutil.pendingChangesExist()
call is made right after. Both calls have asynchronous behavior, which introduces a race condition. I believe that this race condition is to blame for the random build failures.Looking around the file, there is at least another case of this pattern. There might be more in the module if this is a general oversight by the author.
My suggestion is, given the generator/yield approach of the module, the workflow should be adapted to that or, for a smaller refactoring, the code should use
fs.readFileSync
instead. In the latter case, refactoring the code should be trivial. I could create a PR for that if there is consensus about the change.The text was updated successfully, but these errors were encountered: