node:internal/inspector/network_http: `TypeError: Missing dataLength` in event when response uses `setEncoding()`
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, node.js
- 领域
- devtools
调研方向
从lib/internal/inspector/network_http.js开始,追踪将响应块发送给 inspector 的数据监听器。使用一个连接到 inspector 的进程执行https.request并调用response.setEncoding('utf8')来复现;当请求完成且没有出现Missing dataLength错误或响应中止时,即为完成。
由索引模型根据 Issue 内容生成。
描述
Node.js version: 24.21.0 (as bundled in Electron 43.7.3 / VS Code 1.140.0)
Platform: macOS arm64 (likely affects all platforms)
Description
When the V8 inspector is attached and an IncomingMessage response has had setEncoding() called on it, the inspector's data listener in lib/internal/inspector/network_http.js throws TypeError: Missing dataLength in event. This throw propagates through EventEmitter.emit uncaug and causes Node's stream machinery to call destroy(err) on the socket. The caller receives reason: aborted with no indication of the real cause.
Root cause
network_http.js passes chunk.byteLength as dataLength to the C++ NetworkAgent::dataReceived handler. When response.setEncoding('utf8') has been called, Node emits string chunks instead of Buffer
chunks — strings have .length but not .byteLength, so chunk.byteLength is undefined. The C++ ObjectGetInt validation fails and throws.
Suggested fix
// lib/internal/inspector/network_http.js
dataLength: typeof chunk === 'string' ? Buffer.byteLength(chunk) : chunk.byteLength,
Reproduction
Attach the V8 inspector (e.g. VS Code F5 debugger) to a Node process that makes an https.request call and calls response.setEncoding('utf8') in the response handler. The request will abort with reason: aborted instead of completing successfully. The same code works without the debugger attached.
Example
const data = [];
response.setEncoding('utf8')
response.on('data', function (chunk) {
data.push(chunk);
});
response.on('end', function () {
resolve(data.join(''));
});
- 主要语言
- JavaScript
- 星标
- 122k
- 派生
- 39k
- 平均合并
- 3 天 22 小时
- 30 天内合并 PR
- 254
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
nodejs/node 的其他 Issue
-
[Docs] `process.loadEnvFile()` does not document behaviour when variables already exist可能已有人在做 @Sepandard 于 12 天前认领。 未关闭doc
难度 1/5 1 小时以内 新手友好度 90/100
维护者通常 1 天内回复
-
Stream.prototype.forEach will block in first promise in queue before read more chunk可能已有人在做 @mmustafasenoglu 于 12 天前认领。 未关闭doc
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
build
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复
-
`TextEncoder.encodeInto()` underfills the destination for some non-ASCII text可能已有人在做 @XadillaX 于 26 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
nodejs/node#65994 · 2 条评论 · 2 个 reaction ·
维护者通常 1 天内回复
-
[`util.styleText`] Allow `text` param to be any scalar value (ex. `number`, `bool` etc additionaly to `string`) which will be casted internally to `string`可能已有人在做 @SparshGarg999 于 87 天前认领。 未关闭feature request
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
naver/egjs-flicking#971 ·
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
RADAR-base/radar-self-enrolment-ui#118 ·
维护者通常 1 天内回复