[rush](package-deps-hash) Avoid defect to be produced when spawned "git hash-object" process stdin fails while computing repo-state #4478
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4475
As explained in #3517, symlinked directories can't be hashed by
git hash-object
. Whatever the underlying reason is for that, as I already stated in the issue, executed commands should not crash due to this problem and just emit a warning.Note that we might consider this to be a workaround while we fix the root cause which is discarding symlinked directories from the analysis. However I feel like having error handlers there will be worth it anyway as other errors could occur in the future and we definitely don't want to crash the process at this step which is not mandatory for Rush to properly work (file diffing).
Details
I solved the problem by simply attaching an "error" handler on the underlying child process' stdin stream to avoid EPIPE errors (fatal) to occur. This error happens because the git child process closes because of the mentioned errors, but the
stdin
Readable keeps pushing file paths while the Writable is closed.How it was tested
Mainly through manual testing using https://github.com/antoine-coulon/rushelp and the Docker container created from it. The issue can easily be re-created, just run the container, move to
/build
and runrush my-bulk-command
, EPIPE will occur. This is becausegit status
includes/bin
and/lib
symlinked directories so as I said git child process will emit errors.Impacted documentation
None