nodejs / nodejs/node

Expose the "enhanced" stack trace from uncaught exceptions to the `uncaughtException` and `uncaughtExceptionMonitor` handlers on `process`

Abierto
#55,838 9 comentarios 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

events feature request
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?

In my app, I have a logging system which writes entries to files and/or the network in a machine-parsable form. I use the uncaughtException handler on process in order to get uncaught exceptions written out to this logging system. I noticed that if there's no uncaughtException handler, Node will print out an extra stack trace to the console indicating the call site of the <emitter>.emit('error', ...) call which emitted the ultimately-uncaught exception. However, it seems like there's no programmatic way for me to get that extra trace in my own handler.

This feature will solve the problem of being able to programmatically extract this extra — and quite useful! — information in a way that works well with a system that eschews the console.

What is the feature you are proposing to solve the problem?

I don't know what tactic would work best within the larger Node ecosystem, but as a straw-man suggestion:

Add a third argument to the uncaughtException and uncaughtExceptionMonitor callbacks when an "enhanced" error is available, containing information corresponding to the site and target of the emit() call. It could, for example, be a plain object containing an Error representing the call site and an object reference to the emitter itself. But if that's too dangerous, it might instead have strings representing that info. For example (in the former case), the following would nearly duplicate what the current default uncaughtException handler prints out to the console:

process.on('uncaughtException', (err, origin, emitInfo) => {
  console.log('%s', err.stack);
  if (emitInfo) {
    const { emitter, emitSite } = emitInfo;
    console.log(`Emitted 'error' event of ${emitter.constructor.name} instance at:\n%s`,
      emitSite.stack);
  }
});
What alternatives have you considered?

Having a separate process to scrape console output to find things that look like uncaught exceptions, so I can push them into the structured logging system. (Oof.)

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

No se menciona ningún archivo ni prueba en el issue. Empieza rastreando el manejo existente de Node de process uncaughtException y uncaughtExceptionMonitor junto con la ruta de trazas mejorada descrita en el informe. Se considera terminado cuando los handlers puedan recibir mediante programación la información adicional de emit-site y target cuando esté disponible, y el comportamiento esté cubierto por pruebas.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, nodejs
Área
backend
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Activo
Claridad
Necesita aclaración
Aptitud para principiantes
38/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.