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: use child_process.spawn() 'close' signal #39

Merged
merged 1 commit into from
Aug 7, 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
15 changes: 0 additions & 15 deletions .github/workflows/node-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,6 @@ jobs:
npm start -- createcd --input test/fixtures/cue/multiple.cue --output multiple.chd --hunksize 14688
npm start -- info --input multiple.chd

node-e2e:
needs:
- path-filter
if: ${{ needs.path-filter.outputs.changes == 'true' }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-13, macos-14, windows-latest ]
steps:
# Setup and install
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
- run: npm ci
# Test

# !!! This check should be required by GitHub !!!
test-status-check:
if: always()
Expand Down
2 changes: 1 addition & 1 deletion src/chdman/chdmanBin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

proc.stdout.on('data', (chunk) => {
if (options?.logStd) {
console.log(chunk.toString());

Check warning on line 75 in src/chdman/chdmanBin.ts

View workflow job for this annotation

GitHub Actions / node-lint

Unexpected console statement
}

chunks.push(chunk);
Expand All @@ -80,7 +80,7 @@

proc.stderr.on('data', (chunk) => {
if (options?.logStd) {
console.error(chunk.toString());

Check warning on line 83 in src/chdman/chdmanBin.ts

View workflow job for this annotation

GitHub Actions / node-lint

Unexpected console statement
}

chunks.push(chunk);
Expand All @@ -91,7 +91,7 @@
}
});

proc.on('exit', (code) => {
proc.on('close', (code) => {
const output = Buffer.concat(chunks).toString().trim();
if ((code !== null && code !== 0) || killed) {
return reject(output);
Expand Down
4 changes: 1 addition & 3 deletions src/chdman/chdmanHelp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ export default {
* Return info about a CHD file.
*/
async help(attempt = 1): Promise<string> {
const MAX_ATTEMPTS = 3;

const output = await ChdmanBin.run(['help']);

// Try to detect failures, and then retry them automatically
if (!output.trim() && attempt < MAX_ATTEMPTS) {
if (!output.trim() && attempt <= 3) {
await new Promise((resolve) => {
setTimeout(resolve, Math.random() * (2 ** (attempt - 1) * 20));
});
Expand Down
6 changes: 3 additions & 3 deletions src/chdman/chdmanInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ export default {
]);

// Try to detect failures, and then retry them automatically
if (!output.trim() && attempt <= 5) {
if (!output.trim() && attempt <= 3) {
await new Promise((resolve) => {
setTimeout(resolve, Math.random() * (2 ** (attempt - 1) * 10));
setTimeout(resolve, Math.random() * (2 ** (attempt - 1) * 20));
});
return this.info(options, attempt + 1);
}
Expand Down Expand Up @@ -121,7 +121,7 @@ export default {
} satisfies CHDInfo;

// Try to detect failures, and then retry them automatically
if (chdInfo.fileVersion === 0 && attempt <= 5) {
if (chdInfo.fileVersion === 0 && attempt <= 3) {
await new Promise((resolve) => {
setTimeout(resolve, Math.random() * (2 ** (attempt - 1) * 20));
});
Expand Down
Loading