nodejs / nodejs/node

inspector: response.setEncoding() causes response.on('data') never triggered when --experimental-network-inspection is enabled

未关闭
#64,494 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

inspector
主要语言
JavaScript
星标
122k
派生
37.4k
平均合并
4 天 2 小时
30 天内合并 PR
283

描述

Version

v24.17.0

Platform
Windows 11 x64 (10.0.26200)
Subsystem

No response

What steps will reproduce the bug?

When experimental network inspection is enabled, calling response.setEncoding() on an http.IncomingMessage causes Node Inspector to throw exception.
The exception interrupts normal stream processing. response.on("data") callback never triggered.

const http = require('http');

http.get("http://example.com", (response) => {
    response.setEncoding("utf8");

    response.on("data", chunk => {
        console.log(chunk);
    });

    response.on("end", () => {
        console.log("end");
        process.exit(0);
    });

});

Run node --inspect --experimental-network-inspection main.js then open any inspector frontend (Chrome DevTools).

How often does it reproduce? Is there a required condition?

When network inspection feature enabled.

What is the expected behavior? Why is that the expected behavior?

Network inspection should continue to work regardless of whether response.setEncoding() is used.

What do you see instead?

Nodejs throws exception and interrupts normal stream processing. response.on("data") callback never triggered.

Additional information

VSCode extension debugging host enables this feature and breaks my extension development. Waste 2 days to find out why every http request got empty response.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先使用 node --inspect --experimental-network-inspection main.js 和 inspector frontend 运行提供的 HTTP 示例,然后捕获由 response.setEncoding() 触发的异常。跟踪中断流的网络检查处理;当启用编码后,dataend 回调能够正常运行时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, node.js
领域
backend, devtools
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
52/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。