From ba122e63962dae7ad97c768018d62df1dea16cc2 Mon Sep 17 00:00:00 2001 From: adrieljss Date: Mon, 3 Mar 2025 12:51:43 +0800 Subject: [PATCH] fix: return early when aborted --- plugins/http/guest-js/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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) } }