diff --git a/plugins/http/guest-js/index.ts b/plugins/http/guest-js/index.ts index 836f2aad..7787da7e 100644 --- a/plugins/http/guest-js/index.ts +++ b/plugins/http/guest-js/index.ts @@ -202,11 +202,16 @@ export async function fetch( start: (controller) => { streamChannel.onmessage = (res: StreamMessage) => { // close early if aborted - if (signal?.aborted) controller.error(ERROR_REQUEST_CANCELLED) + if (signal?.aborted) { + controller.error(ERROR_REQUEST_CANCELLED) + return + } + if (!res.bytes.length) { controller.close() return } + controller.enqueue(res) } }