UTF-8 represents each Unicode scalar value with one to four bytes. Because a character’s bytes can be split across network chunks, decoding each chunk independently with Buffer.toString("utf8") can produce gibberish. section 11.2.1
Use TextDecoder.decode(chunk, { stream: true }) to decode incrementally. TextDecoder keeps any partial character internally for the next chunk. section 11.2.1
for await (const chunk of res.body) {
resStrings.push(
decoder.decode(chunk, { stream: true }),
);
console.log(resStrings.join(""));
}
This loop decodes each response-body chunk in streaming mode before joining the resulting strings. section 11.2.1












