Skip to content

Commit e59d4d9

Browse files
committed
fetch 'body': don't try to tee() more than once
1 parent 846f8f5 commit e59d4d9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/kit/src/runtime/server/page/load_data.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ export function create_universal_fetch(event, state, fetched, csr, resolve_opts)
263263
}
264264
}
265265

266+
/** @type {ReadableStream<Uint8Array>} */
267+
let teed_body;
268+
266269
const proxy = new Proxy(response, {
267270
get(response, key, _receiver) {
268271
/**
@@ -295,6 +298,7 @@ export function create_universal_fetch(event, state, fetched, csr, resolve_opts)
295298
}
296299

297300
if (key === 'body') {
301+
if (teed_body) return teed_body;
298302
const body = response.body;
299303
if (!body) return body;
300304
const [a, b] = body.tee();
@@ -321,7 +325,7 @@ export function create_universal_fetch(event, state, fetched, csr, resolve_opts)
321325
}
322326
}
323327
reader.read().then(buffer_to_fetched);
324-
return b;
328+
return (teed_body = b);
325329
}
326330

327331
if (key === 'arrayBuffer') {

0 commit comments

Comments
 (0)