node:internal/inspector/network_http: `TypeError: Missing dataLength` in event when response uses `setEncoding()`
Mantenedores costumam responder em até 1 dia
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
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de nodejs/node
-
[Docs] `process.loadEnvFile()` does not document behaviour when variables already existTalvez já em andamento @Sepandard assumiu há 14 dias. Abertadoc
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
Mantenedores costumam responder em até 1 dia
-
Stream.prototype.forEach will block in first promise in queue before read more chunkTalvez já em andamento @mmustafasenoglu assumiu há 15 dias. Abertadoc
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
Mantenedores costumam responder em até 1 dia
-
build
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
nodejs/node#66076 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
`TextEncoder.encodeInto()` underfills the destination for some non-ASCII textTalvez já em andamento @XadillaX assumiu há 28 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
nodejs/node#65994 · 2 comentários · 2 reações ·
Mantenedores costumam responder em até 1 dia
-
[`util.styleText`] Allow `text` param to be any scalar value (ex. `number`, `bool` etc additionaly to `string`) which will be casted internally to `string`Talvez já em andamento @SparshGarg999 assumiu há 90 dias. Abertafeature request
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
nodejs/node#63841 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de nodejs/node
Issues semelhantes
-
bug release:v5.56
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
Jason-Vaughan/TangleClaw#2270 ·
Mantenedores costumam responder em até 1 dia
-
priority: medium tech-debt
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
LeeAdcock/robocodeJs.com#411 ·
Mantenedores costumam responder em até 1 dia
-
status: needs triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
mastra-ai/mastra#26635 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
chore good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
pedrorchagas/blog-api#21 ·