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 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
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
分支
38.4k
平均合併
4 天 2 小時
30 天內合併 PR
261

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

nodejs/node 的其他 Issue

查看 nodejs/node 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。