Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

673
Visualizações
process.on('unhandledRejection') is not logging error

In my server.js file i'm trying to log errors and not cause them to crash the app, this is the code im using

const server = app.listen(3000, () =>
    console.log('Server Up and running')
);

process.on('unhandledRejection', (err, promise) => {
    console.log(`Error: ${err}`);
    server.close(() => process.exit(1));
})

when i produce an error instead of it logging the error and closing the server it just logs the error how it normally would and causes the app to crash. If you need more info let me know. Sorry if this is a dumb question

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I suppose you know the difference between Unhandled Rejection and Uncaught Exception.

it just logs the error how it normally would

Because you're console logging the same error object!

Also don't use process.exit(). Because you might lose your logs. read more

Express docs explained how to do graceful shutdown, you can use similar approach.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda