From 89d9d555d1c4c111e40c6771a214e927562fd363 Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Wed, 22 May 2024 15:08:56 +0000 Subject: [PATCH] stream/internal: use end() instead of destroy() to close response --- src/modules/stream/internal.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/modules/stream/internal.js b/src/modules/stream/internal.js index 9578da9b..fae23f57 100644 --- a/src/modules/stream/internal.js +++ b/src/modules/stream/internal.js @@ -55,8 +55,9 @@ async function handleYoutubeStream(streamInfo, res) { streamInfo.url = req.url; const size = BigInt(req.headers.get('content-length')); - if (req.status !== 200 || !size) - return res.destroy(); + if (req.status !== 200 || !size) { + return res.end(); + } const stream = chunkedStream(streamInfo, size); @@ -66,9 +67,9 @@ async function handleYoutubeStream(streamInfo, res) { } stream.pipe(res); - stream.on('error', () => res.destroy()); + stream.on('error', () => res.end()); } catch { - res.destroy(); + res.end(); } } @@ -94,10 +95,10 @@ export async function internalStream(streamInfo, res) { res.setHeader(name, value) if (req.statusCode < 200 || req.statusCode > 299) - return res.destroy(); + return res.end(); req.body.pipe(res); - req.body.on('error', () => res.destroy()); + req.body.on('error', () => res.end()); } catch { streamInfo.controller.abort(); }