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
- 分支
- 38.4k
- 平均合併
- 4 天 2 小時
- 30 天內合併 PR
- 261
環境準備
- 沒有 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 於 11 天前認領。 未關閉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
-
enhancement
難度 1/5 1 小時以內 新手友好度 90/100
-
app bug config windows-os
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
clawsweeper:needs-product-decision clawsweeper:needs-security-review clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:security issue-rating: 🦞 diamond lobster P2
難度 2/5 1-3 小時 新手友好度 68/100
openclaw/openclaw#166870 · 2 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
⚠ needs intervention document structure changed
難度 2/5 1-3 小時 新手友好度 72/100
-
[Package] Widget primitives [Type] Enhancement
難度 2/5 1-3 小時 新手友好度 85/100
WordPress/gutenberg#84204 · 1 則留言 ·
維護者通常 1 天內回覆