Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

node:internal/inspector/network_http: `TypeError: Missing dataLength` in event when response uses `setEncoding()`

未关闭 适合新手
#66,551 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@lazerg 已经在做这个了。

开始于 2026年10月6日。

  • #66552 来自 @lazerg —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
领域
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

环境准备

从这里开始

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

nodejs/node 的其他 Issue

查看 nodejs/node 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

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