Skip to content

Commit dee8f4c

Browse files
committed
fix: avoid body stream already read on fallback
1 parent 004f4e5 commit dee8f4c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/util/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export const downloadWithProgress = async (
106106
cb?: ProgressCallback
107107
): Promise<ArrayBuffer> => {
108108
const resp = await fetch(url);
109+
const fallback = resp.clone();
109110
let buf;
110111

111112
try {
@@ -143,7 +144,7 @@ export const downloadWithProgress = async (
143144
} catch (e) {
144145
console.log(`failed to send download progress event: `, e);
145146
// Fetch arrayBuffer directly when it is not possible to get progress.
146-
buf = await resp.arrayBuffer();
147+
buf = await fallback.arrayBuffer();
147148
cb &&
148149
cb({
149150
url,

0 commit comments

Comments
 (0)