Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

332
Vistas
What is the default behaviour of Node.js on receiving SIGTERM?

I've been reading documentation and it's not explicitly stated whether the Node.js process immediately exits or not if no signal handler is registered. For example, are pending tasks in the poll queue executed or is everything dropped? Does the programmer always have to handle graceful shutdown explicitly by keeping track of all pending promises?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

When no handler is added for SIGTERM, node will reset the terminal and exit the process immediately. It's a "drop everything where it is" exit. Even more so than so than process.exit which does still allow the exit event to fire:

Calling process.exit() will force the process to exit as quickly as possible even if there are still asynchronous operations pending that have not yet completed fully, including I/O operations to process.stdout and process.stderr.

When a signal handler is added (process.once('SIGTERM'), the handler code is scheduled for the next event loop. So behaviour immediately changes even if you just call process.exit() in the handler.

Promises, or Javascript generally for that matter, don't have the concept of cancellation built in yet. You could track promises but unless the underlying API's being used specifically address ways to cancel tasks then there's not much to do.

You can just wait though. In the average web application if you close the web server and close the database connection. Existing connections will complete, no new connections will initiate, eventually the process will exit by itself when there is nothing left on the event loop to run. wtfnode can be handy to help debug processes that aren't eventually exiting like this.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda