Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Git exec(): child killed by a signal rejects with new Error('') and loses the signal information

オープン 初心者向け
#84 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
node.js, typescript
領域
tooling

調査の方向性

src/util/git.ts の内部 exec ヘルパーから始め、Node の code 引数と signal 引数を含む close イベントリスナーを調べます。出力がなくてもゼロ以外の終了コードと終了シグナルが伝達されるように拒否の動作を更新し、その後、ヘルパーの正常終了、失敗、シグナルによる終了の各経路を検証します。

索引モデルが issue の本文から書いたものです。

説明

bug S3

Observed behavior

The internal exec helper in src/util/git.ts resolves/rejects on the close event:

cmdProcess.on('close', (code: number): void => {
  if (code === 0) {
    resolve(outputs.join(''));
  } else {
    reject(new Error(outputs.join('')));
  }
});

Node's documentation says code may be null if the child was terminated by a signal (the signal name is the second argument to the listener). In that case:

  1. The type annotation code: number is wrong (it can be null).
  2. The rejection becomes new Error('') if the child was killed before producing any output, with no indication that it was killed or by which signal.

Expected behavior

The error should communicate either the non-zero exit code or the signal name, so a caller (or a developer reading logs) can tell why git terminated.

Minimal reproduction

import { spawn } from 'node:child_process';
const child = spawn('sleep', ['10']);
const outputs = [];
child.stdout?.on('data', d => outputs.push(String(d)));
child.stderr?.on('data', d => outputs.push(String(d)));
child.on('close', (code, signal) => {
  console.log('code=', code, 'signal=', signal);
  if (code === 0) { console.log('resolve', JSON.stringify(outputs.join(''))); }
  else { console.log('reject', JSON.stringify(outputs.join(''))); }
});
setTimeout(() => child.kill('SIGTERM'), 50);
// -> code= null signal= SIGTERM
// -> reject \"\"

Suggested fix

cmdProcess.on('close', (code: number | null, signal: NodeJS.Signals | null): void => {
  if (code === 0) {
    resolve(outputs.join(''));
    return;
  }
  const detail = outputs.join('');
  const reason = signal != null
    ? `git was killed by ${signal}`
    : `git exited with code ${code}`;
  reject(new Error(detail ? `${reason}: ${detail}` : reason));
});
主要言語
TypeScript
スター
2
フォーク
1
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

joewalker/loop-the-loop のほかの issue

joewalker/loop-the-loop の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。