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

[rush](package-deps-hash) Avoid defect to be produced when spawned "git hash-object" process stdin fails while computing repo-state #4478

Merged
merged 4 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/package-deps-hash",
"comment": "Handle an edge case in `getRepoState` wherein it tries to asynchronously pipe data to `git hash-object` but the subprocess has already exited.",
"type": "patch"
}
],
"packageName": "@rushstack/package-deps-hash"
}
1 change: 0 additions & 1 deletion libraries/package-deps-hash/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
},
"devDependencies": {
"@rushstack/heft": "workspace:*",
"@rushstack/node-core-library": "workspace:*",
"local-node-rig": "workspace:*"
},
"dependencies": {
Expand Down
9 changes: 7 additions & 2 deletions libraries/package-deps-hash/src/getRepoState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import type * as child_process from 'child_process';
import { once } from 'events';
import { Readable } from 'stream';
import { Readable, pipeline } from 'stream';

import { Executable, FileSystem, type IExecutableSpawnOptions } from '@rushstack/node-core-library';

Expand Down Expand Up @@ -282,7 +282,12 @@ async function spawnGitAsync(
});

if (stdin) {
stdin.pipe(proc.stdin!);
/**
* For `git hash-object` data is piped in asynchronously. In the event that one of the
* passed filenames cannot be hashed, subsequent writes to `proc.stdin` will error.
* Silence this error since it will be handled by the non-zero exit code of the process.
*/
pipeline(stdin, proc.stdin!, (err) => {});
}

const [status] = await once(proc, 'exit');
Expand Down
Loading