Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#66,551 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@lazerg ci sta già lavorando.

Dal 6/10/2026.

  • #66552 di @lazerg — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, node.js
Ambito
devtools

Direzione di ricerca

Inizia da lib/internal/inspector/network_http.js e segui il listener dei dati che invia i chunk della risposta all'inspector. Riproduci il problema con un processo collegato all'inspector che esegue una https.request e chiama response.setEncoding('utf8'); il lavoro è completato quando la richiesta termina senza l'errore Missing dataLength né una risposta interrotta.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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(''));
});
Lingua principale
JavaScript
Stelle
122k
Fork
39k
Merge medio
3g 22h
PR unite (30g)
245

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nodejs/node

Tutte le issue di nodejs/node

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.