Add passive signal observers
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 122k
- フォーク
- 37.3k
- 平均マージ
- 4日 2時間
- マージ済み PR(30日)
- 283
説明
What is the problem this feature will solve?
Node currently exposes signals through process.on('SIGINT') / process.on('SIGTERM'), but that API combines two very different needs:
- observing that a signal happened
- taking ownership of shutdown behavior
That coupling creates avoidable ecosystem friction. Many libraries only need best-effort cleanup when a process is interrupted, for example restoring terminal state, showing the cursor again, or stopping a spinner. Today, the only way to do that is to install a real signal handler, which changes global process semantics, suppresses default behavior, and can interfere with app-defined handlers.
What is the feature you are proposing to solve the problem?
Node should add a passive API such as:
process.observeSignal('SIGINT', () => {
restoreTerminalState();
});
A passive observer would be notified when the signal arrives, but would not count as a handler, would not suppress Node's default behavior, and would not affect app ownership of signal handling. Apps that want to intercept or overrride shutdown would continue to use process.on(...).
This would give Node a clean separation between "tell me this happened" and "I am handling this". It solves a real problem for CLI and terminal libraries, reduces handler conflicts, preserves backward compatibility, and makes signal behavior more predictable across the ecosystem.
What alternatives have you considered?
Considered alternatives:
-
Reuse
process.on()/process.once()
Rejected because it does not separate observation from handling. Libraries still become real signal handlers and can change global process behavior. -
Rely on exit hooks like
exit/beforeExit
Rejected because they are not signal-specific and are too late or inconsistent for cleanup that should happen when the signal is delivered. -
Tell libraries to avoid signals entirely
Rejected because it pushes the problem onto every app and leaves reusable CLI libraries without a clean way to do best-effort cleanup. -
Add ordering, priority, or metadata to existing signal handlers
Rejected because it may reduce conflicts, but it still treats passive observers as active handlers. Th core problem remains.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、Node に既に存在する process.on('SIGINT') と process.on('SIGTERM') のシグナル処理、および issue で説明されている exit と beforeExit の代替手段を確認します。デフォルトの動作とアプリケーションが定義した所有権を維持することを含め、パッシブオブザーバーが実際のハンドラーと異なり何をしなければならないかを定義します。提案する API とそのシグナルセマンティクスが実装に十分な明確さで仕様化されていれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, node.js
- 領域
- operating-systems
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100