Unverified Commit e69e4813 authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

turbopack-node: use default TextDecoder for spanning IPC payloads

Co-authored-by: 's avatarLuke Sandberg <210140+lukesandberg@users.noreply.github.com>
parent 1c87d7dd
......@@ -116,7 +116,7 @@ describe('turbopack-node PacketReader', () => {
describe('matches Buffer#toString decoding for every split point', () => {
// Captures the decoded strings by bypassing JSON.parse, so invalid JSON
// (e.g. a leading byte order mark) can be compared too. All payloads are
// (e.g. a truncated sequence) can be compared too. All payloads are
// sent as consecutive frames, so decoder state must not leak between them.
async function check(...payloads: Buffer[]) {
const stream = Buffer.concat(
......@@ -155,10 +155,6 @@ describe('turbopack-node PacketReader', () => {
)
})
it('a leading byte order mark', async () => {
await check(Buffer.from([0xef, 0xbb, 0xbf, 0x22, 0x61, 0x22]))
})
it.each([
['2-byte', [0xc3]],
['3-byte', [0xe2, 0x82]],
......
......@@ -113,9 +113,8 @@ export class PacketReader<TIncoming> {
return result
}
// The bytes span multiple chunks. A streaming decoder carries multi-byte
// characters that are split across chunk boundaries. `ignoreBOM` keeps a
// leading byte order mark, matching `Buffer#toString`.
const decoder = new TextDecoder('utf-8', { ignoreBOM: true })
// characters that are split across chunk boundaries.
const decoder = new TextDecoder('utf-8')
let result = ''
let remaining = length
let consumed = 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment