fix: return early when aborted

pull/2479/head
adrieljss 5 months ago
parent 0a0a428094
commit ba122e6396
No known key found for this signature in database
GPG Key ID: 849F13CBD0B4AD05

@ -202,11 +202,16 @@ export async function fetch(
start: (controller) => { start: (controller) => {
streamChannel.onmessage = (res: StreamMessage) => { streamChannel.onmessage = (res: StreamMessage) => {
// close early if aborted // 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) { if (!res.bytes.length) {
controller.close() controller.close()
return return
} }
controller.enqueue(res) controller.enqueue(res)
} }
} }

Loading…
Cancel
Save