Add passive signal observers
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- JavaScript
- Estrellas
- 122k
- Forks
- 37.3k
- Merge medio
- 4 d 2 h
- PR fusionados (30 d)
- 283
Descripción
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.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza revisando el manejo de señales existente de Node mediante process.on('SIGINT') y process.on('SIGTERM'), junto con las alternativas exit y beforeExit descritas en el issue. Define qué debe hacer de forma diferente un observador pasivo frente a un manejador real, incluida la preservación del comportamiento predeterminado y de la responsabilidad definida por la aplicación. Se considera terminado cuando la API propuesta y la semántica de sus señales están especificadas con suficiente claridad para su implementación.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript, node.js
- Área
- operating-systems
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100