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

265
Visualizações
How to get all local variables in Node.js when an uncaught exception happens?

Whenever my node.js script has an uncaught exception. I'd like to be able to dump all the local variables to the console implicitly so that I can have a snapshot of all the values the moment anything went wrong.

Right now I can do this with visual code by having a debugger running, but is this possible to do using just code?

If not, what would be the best way to invoke a debugger to attach to the node script and dump the variables when an exception occurs?

Currently the built in node.js debugger has the watch() method for getting the variable values on an exception, but it requires that you implicitly specify the variable before the exception occurs.

There is the chrome v8 debugger using --inspect argument and visiting chrome://inspect/ in chrome, but that would require automating chrome using the Chrome DevTools Protocol.

It also requires an instance of chrome to be running which is too resource intensive on a VPS that has the minimum specs.

What is the best way to dump the local variables to a log file when something goes wrong?

about 4 years ago · Juan Pablo Isaza
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