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

fix(core): git hash-object errors must be logged for troubleshooting #10134

Merged

Conversation

jonhamm
Copy link
Contributor

@jonhamm jonhamm commented May 4, 2022

When executing parallel targets using e.g. run-commands missing entries in .gitignore
may lead to temp files being passed to "git hash-object"
which when git executes have been deleted resulting in
mismatch between number of files requested and hashes returned.
git reports the error and this PR will make sure that report is passed in the error thrown.
This will make problem resolution a lot faster.

ISSUES CLOSED: #9946

Current Behavior

If some directory - e.g. .npm - is not present in .gitignore parallel builds adding and removing files in such a temporary directory may result in these files being passed to git hash-object.
This will show up as an error:
> NX Passed 11161 file paths to Git to hash, but received 11148 hashes.
and the build fails.
Trouble shooting this is a bit hard because there is no hint as to which file(s) were between gathering files and requesting hash calculation.

Expected Behavior

The error output from git hash-object will show at least one of the files that could not be hashed.
We want this error info in the log along with the current - e.g.

> NX Passed 2 file paths to Git to hash, but received 1 hashes.
fatal: Cannot open 'b.txt': No such file or directory
```

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is merged. -->

Fixes #

The `spawnProcess()` that is used to invoke `git hash-object` now returns both `stdout` and `stderr`.
If the caller discovers a discrepancy between the number of files passed to `git hash-object` and the number of hashes returned an error is thrown (as previously) but now this error will also contain `stderrr`

@nx-cloud
Copy link

nx-cloud bot commented May 4, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit e1f39f6. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 12 targets

Sent with 💌 from NxCloud.

@vercel
Copy link

vercel bot commented May 4, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
nx-dev ✅ Ready (Inspect) Visit Preview May 5, 2022 at 6:04AM (UTC)

…og one of the missing files

When executing parallel targets using e.g. run-commands missing entries in .gitignore
may lead to
temp files being passed to "git hash-object"
which when git executes have been deleted
resulting in
mismatch between number of files requested and hashes returned.
git reports the error and this PR
will make sure that report is passed
in the error thrown.
This will make problem resolution a lot
faster.

ISSUES CLOSED: nrwl#9946
Copy link
Collaborator

@FrozenPandaz FrozenPandaz left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution! LGTM 🎉

These errors will help us fix the issues people are seeing.

@FrozenPandaz FrozenPandaz merged commit 0ec1a62 into nrwl:master May 6, 2022
@jonhamm jonhamm deleted the report-errors-from-git-hash-object branch March 7, 2023 08:54
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NX Passed 11161 file paths to Git to hash, but received 11148 hashes.
2 participants