X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Frequests.ts;h=36e69458e533064a584e93a061d6361b57dc4db6;hb=fbd67e7f386504e50f2504cb6386700a58906f16;hp=fd2a56f30c717e6ce892b1fd90deca6af228a327;hpb=e7053b1d9d7f77d0375155b38d3e845f2163ecd8;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts index fd2a56f30..36e69458e 100644 --- a/server/helpers/requests.ts +++ b/server/helpers/requests.ts @@ -2,7 +2,7 @@ import { createWriteStream, remove } from 'fs-extra' import got, { CancelableRequest, Options as GotOptions, RequestError } from 'got' import { join } from 'path' import { CONFIG } from '../initializers/config' -import { ACTIVITY_PUB, PEERTUBE_VERSION, WEBSERVER } from '../initializers/constants' +import { ACTIVITY_PUB, PEERTUBE_VERSION, REQUEST_TIMEOUT, WEBSERVER } from '../initializers/constants' import { pipelinePromise } from './core-utils' import { processImage } from './image-utils' import { logger } from './logger' @@ -24,6 +24,7 @@ type PeerTubeRequestOptions = { key: string headers: string[] } + timeout?: number jsonResponse?: boolean } & Pick @@ -92,6 +93,10 @@ const peertubeGot = got.extend({ path }, httpSignatureOptions) } + }, + + (options: GotOptions) => { + options.timeout = REQUEST_TIMEOUT } ] } @@ -180,8 +185,10 @@ function buildGotOptions (options: PeerTubeRequestOptions) { return { method: options.method, + dnsCache: true, json: options.json, searchParams: options.searchParams, + timeout: options.timeout ?? REQUEST_TIMEOUT, headers, context }