From cda0351a2b892239937ad0334fcaef848675dc85 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 15 Jan 2025 14:46:08 +0100 Subject: [PATCH] Fix proxy conflict --- server/core/helpers/requests.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/server/core/helpers/requests.ts b/server/core/helpers/requests.ts index 5d3af5e8a..dee90b9f8 100644 --- a/server/core/helpers/requests.ts +++ b/server/core/helpers/requests.ts @@ -177,7 +177,14 @@ export function generateRequestStream (url: string, options: PeerTubeRequestOpti } export function getProxyAgent () { - if (!isProxyEnabled()) return {} + if (!isProxyEnabled()) { + return { + agent: { // Fix issue https://github.com/node-fetch/node-fetch/issues/1735 with Node 20 + http: new http.Agent({ keepAlive: false }), + https: new https.Agent({ keepAlive: false }) + } + } + } const proxy = getProxy() @@ -230,10 +237,6 @@ function buildGotOptions (options: PeerTubeRequestOptions): OptionsOfUnknownResp return { method: options.method, dnsCache: true, - agent: { // Fix issue https://github.com/node-fetch/node-fetch/issues/1735 with Node 20 - http: new http.Agent({ keepAlive: false }), - https: new https.Agent({ keepAlive: false }) - }, timeout: { request: options.timeout ?? REQUEST_TIMEOUTS.DEFAULT },