[chore] Fix type errors

This commit is contained in:
Cohee
2024-10-11 21:33:36 +03:00
parent 72138c632d
commit 4fcad0752f
25 changed files with 78 additions and 44 deletions

View File

@ -441,17 +441,21 @@ export function forwardFetchResponse(from, to) {
to.statusCode = statusCode;
to.statusMessage = statusText;
from.body.pipe(to);
if (from.body && to.socket) {
from.body.pipe(to);
to.socket.on('close', function () {
if (from.body instanceof Readable) from.body.destroy(); // Close the remote stream
to.end(); // End the Express response
});
to.socket.on('close', function () {
if (from.body instanceof Readable) from.body.destroy(); // Close the remote stream
to.end(); // End the Express response
});
from.body.on('end', function () {
console.log('Streaming request finished');
from.body.on('end', function () {
console.log('Streaming request finished');
to.end();
});
} else {
to.end();
});
}
}
/**