Fix requests on node 20

This commit is contained in:
Chocobozzz 2025-01-15 14:15:50 +01:00
parent fcff0ce69f
commit b6eb8de3a0
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 48 additions and 37 deletions

View File

@ -139,7 +139,7 @@
"flat": "^6.0.1",
"fluent-ffmpeg": "^2.1.0",
"fs-extra": "^11.1.0",
"got": "^13.0.0",
"got": "^14.4.5",
"got-ssrf": "^3.0.0",
"helmet": "^7.0.0",
"http-problem-details": "^0.1.5",

View File

@ -4,6 +4,8 @@ import { createWriteStream } from 'fs'
import { remove } from 'fs-extra/esm'
import got, { CancelableRequest, OptionsInit, OptionsOfTextResponseBody, OptionsOfUnknownResponseBody, RequestError, Response } from 'got'
import { gotSsrf } from 'got-ssrf'
import http from 'http'
import https from 'https'
import { HttpProxyAgent, HttpsProxyAgent } from '../helpers/hpagent.js'
import { ACTIVITY_PUB, BINARY_CONTENT_TYPES, PEERTUBE_VERSION, REQUEST_TIMEOUTS, WEBSERVER } from '../initializers/constants.js'
import { pipelinePromise } from './core-utils.js'
@ -228,6 +230,10 @@ 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
},

View File

@ -1948,10 +1948,10 @@
unordered-array-remove "^1.0.2"
xml2js "^0.6.0"
"@sindresorhus/is@^5.2.0":
version "5.6.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-5.6.0.tgz#41dd6093d34652cddb5d5bdeee04eafc33826668"
integrity sha512-TV7t8GKYaJWsn00tFDqBw8+Uqmr8A0fRU1tvTQhyZzGv0sJCGRQL3JGMI3ucuKo3XIZdUP+Lx7/gh2t3lewy7g==
"@sindresorhus/is@^7.0.1":
version "7.0.1"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-7.0.1.tgz#693cd0bfa7fdc71a3386b72088b660fb70851927"
integrity sha512-QWLl2P+rsCJeofkDNIT3WFmb6NrRud1SUYW8dIhXK/46XFV8Q/g7Bsvib0Askb0reRLe+WYPeeE+l5cH7SlkuQ==
"@sindresorhus/merge-streams@^4.0.0":
version "4.0.0"
@ -2664,7 +2664,7 @@
"@types/jsonfile" "*"
"@types/node" "*"
"@types/http-cache-semantics@^4.0.2":
"@types/http-cache-semantics@^4.0.4":
version "4.0.4"
resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz#b979ebad3919799c979b17c72621c0bc0a31c6c4"
integrity sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA==
@ -3935,17 +3935,17 @@ cacheable-lookup@^7.0.0:
resolved "https://registry.yarnpkg.com/cacheable-lookup/-/cacheable-lookup-7.0.0.tgz#3476a8215d046e5a3202a9209dd13fec1f933a27"
integrity sha512-+qJyx4xiKra8mZrcwhjMRMUhD5NR1R8esPkzIYxX96JiecFoxAXFuz/GpR3+ev4PE1WamHip78wV0vcmPQtp8w==
cacheable-request@^10.2.8:
version "10.2.14"
resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-10.2.14.tgz#eb915b665fda41b79652782df3f553449c406b9d"
integrity sha512-zkDT5WAF4hSSoUgyfg5tFIxz8XQK+25W/TLVojJTMKBaxevLBBtLxgqguAuVQB8PVW79FVjHcU+GJ9tVbDZ9mQ==
cacheable-request@^12.0.1:
version "12.0.1"
resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-12.0.1.tgz#e6f473b5b76c02e72a0ec2cd44c7cfb7c751d7c5"
integrity sha512-Yo9wGIQUaAfIbk+qY0X4cDQgCosecfBe3V9NSyeY4qPC2SAkbCS4Xj79VP8WOzitpJUZKc/wsRCYF5ariDIwkg==
dependencies:
"@types/http-cache-semantics" "^4.0.2"
get-stream "^6.0.1"
"@types/http-cache-semantics" "^4.0.4"
get-stream "^9.0.1"
http-cache-semantics "^4.1.1"
keyv "^4.5.3"
keyv "^4.5.4"
mimic-response "^4.0.0"
normalize-url "^8.0.0"
normalize-url "^8.0.1"
responselike "^3.0.0"
call-bind@^1.0.2, call-bind@^1.0.5, call-bind@^1.0.6, call-bind@^1.0.7:
@ -5891,10 +5891,10 @@ foreground-child@^3.1.0:
cross-spawn "^7.0.0"
signal-exit "^4.0.1"
form-data-encoder@^2.1.2:
version "2.1.4"
resolved "https://registry.yarnpkg.com/form-data-encoder/-/form-data-encoder-2.1.4.tgz#261ea35d2a70d48d30ec7a9603130fa5515e9cd5"
integrity sha512-yDYSgNMraqvnxiEXO4hi88+YZxaHC6QKzb5N84iRCTDeRO7ZALpir/lVmf/uXUhnwUr2O4HU8s/n6x+yNjQkHw==
form-data-encoder@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/form-data-encoder/-/form-data-encoder-4.0.2.tgz#dd286fd5f9049e8ded1d44ce427f5e29185c7c12"
integrity sha512-KQVhvhK8ZkWzxKxOr56CPulAhH3dobtuQ4+hNQ+HekH/Wp5gSOafqRAeTphQUJAIk0GBvHZgJ2ZGRWd5kphMuw==
form-data@^4.0.0:
version "4.0.1"
@ -6077,12 +6077,12 @@ get-stream@^3.0.0:
resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14"
integrity sha512-GlhdIUuVakc8SJ6kK0zAFbiGzRFzNnY4jUuEbV9UROo4Y+0Ny4fjvcZFVTeDA4odpFyOQzaw6hXukJSq/f28sQ==
get-stream@^6.0.0, get-stream@^6.0.1:
get-stream@^6.0.0:
version "6.0.1"
resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7"
integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==
get-stream@^9.0.0:
get-stream@^9.0.0, get-stream@^9.0.1:
version "9.0.1"
resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-9.0.1.tgz#95157d21df8eb90d1647102b63039b1df60ebd27"
integrity sha512-kVCxPF3vQM/N0B1PmoqVUqgHP+EeVjmZSQn+1oCRPxd2P21P2F19lIgbR3HBosbB1PUhOAoctJnfEn2GbN2eZA==
@ -6257,22 +6257,22 @@ got-ssrf@^3.0.0:
debug "^4.3.2"
ipaddr.js "^2.0.1"
got@^13.0.0:
version "13.0.0"
resolved "https://registry.yarnpkg.com/got/-/got-13.0.0.tgz#a2402862cef27a5d0d1b07c0fb25d12b58175422"
integrity sha512-XfBk1CxOOScDcMr9O1yKkNaQyy865NbYs+F7dr4H0LZMVgCj2Le59k6PqbNHoL5ToeaEQUYh6c6yMfVcc6SJxA==
got@^14.4.5:
version "14.4.5"
resolved "https://registry.yarnpkg.com/got/-/got-14.4.5.tgz#49a8b49a49a851d658b19e2d1b97e50ef8903f17"
integrity sha512-sq+uET8TnNKRNnjEOPJzMcxeI0irT8BBNmf+GtZcJpmhYsQM1DSKmCROUjPWKsXZ5HzwD5Cf5/RV+QD9BSTxJg==
dependencies:
"@sindresorhus/is" "^5.2.0"
"@sindresorhus/is" "^7.0.1"
"@szmarczak/http-timer" "^5.0.1"
cacheable-lookup "^7.0.0"
cacheable-request "^10.2.8"
cacheable-request "^12.0.1"
decompress-response "^6.0.0"
form-data-encoder "^2.1.2"
get-stream "^6.0.1"
http2-wrapper "^2.1.10"
form-data-encoder "^4.0.2"
http2-wrapper "^2.2.1"
lowercase-keys "^3.0.0"
p-cancelable "^3.0.0"
p-cancelable "^4.0.1"
responselike "^3.0.0"
type-fest "^4.26.1"
graceful-fs@^4.1.6, graceful-fs@^4.2.0:
version "4.2.11"
@ -6468,7 +6468,7 @@ http2-express-bridge@^1.0.7:
send "^0.17.1"
setprototypeof "^1.2.0"
http2-wrapper@^2.1.10:
http2-wrapper@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/http2-wrapper/-/http2-wrapper-2.2.1.tgz#310968153dcdedb160d8b72114363ef5fce1f64a"
integrity sha512-V5nVw1PAOgfI3Lmeaj2Exmeg7fenjhRUgz1lPSezy1CuhPYbgQtbQj4jZfEAEMlaL+vupsvhjqCyjzob0yxsmQ==
@ -7276,7 +7276,7 @@ k-rpc@^5.1.0:
k-rpc-socket "^1.7.2"
randombytes "^2.0.5"
keyv@^4.5.3:
keyv@^4.5.3, keyv@^4.5.4:
version "4.5.4"
resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93"
integrity sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==
@ -8181,7 +8181,7 @@ normalize-path@^3.0.0, normalize-path@~3.0.0:
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65"
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==
normalize-url@^8.0.0:
normalize-url@^8.0.1:
version "8.0.1"
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-8.0.1.tgz#9b7d96af9836577c58f5883e939365fa15623a4a"
integrity sha512-IO9QvjUMWxPQQhs60oOu10CRkWCiZzSUkzbXGGV9pviYl1fXYcvkzQ5jV9z8Y6un8ARoVRl4EtC6v6jNqbaJ/w==
@ -8379,10 +8379,10 @@ otpauth@^9.0.2:
dependencies:
"@noble/hashes" "1.5.0"
p-cancelable@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-3.0.0.tgz#63826694b54d61ca1c20ebcb6d3ecf5e14cd8050"
integrity sha512-mlVgR3PGuzlo0MmTdk4cXqXWlwQDLnONTAg6sm62XkMJEiRxN3GL3SffkYvqwonbkJBcrI7Uvv5Zh9yjvn2iUw==
p-cancelable@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-4.0.1.tgz#2d1edf1ab8616b72c73db41c4bc9ecdd10af640e"
integrity sha512-wBowNApzd45EIKdO1LaU+LrMBwAcjfPaYtVzV3lmfM3gf8Z4CHZsiIqlM8TZZ8okYvh5A1cP6gTfCRQtwUpaUg==
p-event@4.2.0:
version "4.2.0"
@ -10576,6 +10576,11 @@ type-fest@^0.20.2:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4"
integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==
type-fest@^4.26.1:
version "4.32.0"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-4.32.0.tgz#55bacdd6f2cf1392b7e9cde894e9b1d726807e97"
integrity sha512-rfgpoi08xagF3JSdtJlCwMq9DGNDE0IMh3Mkpc1wUypg9vPi786AiqeBBKcqvIkq42azsBM85N490fyZjeUftw==
type-is@1.6.18, type-is@^1.6.4, type-is@~1.6.18:
version "1.6.18"
resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131"