Skip to content

Commit

Permalink
fix: convert buffer to uint8array for readablestream (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
AuHau authored Dec 7, 2021
1 parent a69b8a0 commit 7f34ea6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/utils/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ export function readableNodeToWeb(nodeStream: NodeReadableType): ReadableStream<
start(controller) {
nodeStream.pause()
nodeStream.on('data', chunk => {
controller.enqueue(chunk)
if (Buffer.isBuffer(chunk)) {
controller.enqueue(new Uint8Array(chunk.buffer))
} else {
controller.enqueue(chunk)
}
nodeStream.pause()
})
nodeStream.on('end', () => controller.close())
Expand Down

0 comments on commit 7f34ea6

Please sign in to comment.