Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta Para iniciantes
#66,551 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@lazerg já está trabalhando nisso.

Desde 6/10/2026.

  • #66552 de @lazerg — aberto

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
78/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
javascript, node.js
Domínio
devtools

Direção de pesquisa

Comece em lib/internal/inspector/network_http.js e rastreie o listener de dados que envia os chunks da resposta ao inspector. Reproduza o problema com um processo conectado ao inspector que faça uma https.request e chame response.setEncoding('utf8'); a tarefa estará concluída quando a requisição terminar sem o erro Missing dataLength nem uma resposta interrompida.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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(''));
});
Linguagem predominante
JavaScript
Estrelas
122k
Forks
39k
Merge médio
3d 22h
PRs com merge (30d)
244

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de nodejs/node

Todas as issues de nodejs/node

Issues semelhantes

Mais issues de JavaScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.