namespaces returned by debug.disable are not always accepted by debug.enable

Abierto
#918 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
javascript
Área
tooling

Línea de trabajo

Start in common.js at the enable implementation around line 184 and reproduce the issue with DEBUG=":error:". Trace how debug.disable() transforms the namespace before it is passed back to debug.enable(). Done means the namespace returned by disable() can be passed to enable() without an invalid regular expression error.

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

Descripción

bug

I have seen some strange behavior when temporary disabling the current namespaces, and trying to re-enable the namespaces returned by the debug.disable() call later in the debug.enable() call.
This happened while debugging a node-red custom node that I'm working on:

First I start node-red with some logging enabled:
DEBUG="*:error:*" node-red
Then using a REST call i fetch the current namespaces as follows:

    RED.httpAdmin.get('/debug', function (req, res) {
        console.log("/debug",req.method);
        var namespaces = debug.disable();
        console.log("/debug",req.method,namespaces);
        debug.enable(namespaces);
        res.end(JSON.stringify(Object({ "namespaces": namespaces })));
    });

When this function is called, it prints the following on the console:

/debug GET
/debug GET .*?:error:*
SyntaxError: Invalid regular expression: /^..*??:error:.*?$/: Nothing to repeat
    at new RegExp (<anonymous>)
    at Function.enable (/home/hurenkam/Workspace/node-red-contrib-mh-hue/node_modules/debug/src/common.js:184:28)
    at /home/hurenkam/Workspace/node-red-contrib-mh-hue/src/debug.js:21:15
    at Layer.handle [as handle_request] (/usr/local/lib/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
    at next (/usr/local/lib/node_modules/node-red/node_modules/express/lib/router/route.js:144:13)
    at Route.dispatch (/usr/local/lib/node_modules/node-red/node_modules/express/lib/router/route.js:114:3)
    at Layer.handle [as handle_request] (/usr/local/lib/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
    at /usr/local/lib/node_modules/node-red/node_modules/express/lib/router/index.js:284:15
    at Function.process_params (/usr/local/lib/node_modules/node-red/node_modules/express/lib/router/index.js:346:12)
    at next (/usr/local/lib/node_modules/node-red/node_modules/express/lib/router/index.js:280:10)

It would seem that the wildcard namespace "*:error:*" is being translated to ".*?:error:*" which when fed back into debug.enable() triggers an error in common.js @ line 184 when trying to push the expression into a RegExp:

common.js:
184: createDebug.names.push(new RegExp('^' + namespaces + '$'));

Lenguaje dominante
JavaScript
Estrellas
11.5k
Forks
992
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

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.

Más de debug-js/debug

Todos los issues de debug-js/debug

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.