namespaces returned by debug.disable are not always accepted by debug.enable
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript
- 领域
- tooling
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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 + '$'));
- 主要语言
- JavaScript
- 星标
- 11.5k
- 派生
- 993
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
debug-js/debug 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 82/100
-
难度 4/5 3-5 天 新手友好度 25/100
-
Debug as JSON未关闭
难度 5/5 一周以上 新手友好度 25/100
-
难度 3/5 1-2 天 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 28/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
CopilotKit/aimock#491 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
keyxmakerx/Chronicle#967 ·
维护者通常 1 天内回复
-
good first issue hacktoberfest
难度 1/5 1 小时以内 新手友好度 92/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 92/100
DietrichGebert/ponytail#978 ·
维护者通常 2 天内回复
-
bug component: bulk editor support
难度 2/5 1-3 小时 新手友好度 78/100
Yoast/wordpress-seo#23669 ·
维护者通常 3 天内回复