From 4a9b40b717dc7e5be59bbd4e56670d27995faf58 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Fri, 21 May 2021 10:11:53 +0900 Subject: fix(runtime/http): fix empty blob response (#10689) --- runtime/js/40_http.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/js/40_http.js b/runtime/js/40_http.js index eb4d214ca..d4b658314 100644 --- a/runtime/js/40_http.js +++ b/runtime/js/40_http.js @@ -132,10 +132,13 @@ } else { const reader = innerResp.body.stream.getReader(); const r1 = await reader.read(); - if (r1.done) throw new TypeError("Unreachable"); - respBody = r1.value; - const r2 = await reader.read(); - if (!r2.done) throw new TypeError("Unreachable"); + if (r1.done) { + respBody = new Uint8Array(0); + } else { + respBody = r1.value; + const r2 = await reader.read(); + if (!r2.done) throw new TypeError("Unreachable"); + } } } else { innerResp.body.streamOrStatic.consumed = true; -- cgit v1.2.3