From 7500d6c9000b531fda1fd64e188b7cf83803941a Mon Sep 17 00:00:00 2001 From: Chocobozzz <me@florianbigard.com> Date: Mon, 14 Jun 2021 18:06:58 +0200 Subject: Use a global request timeout --- server/helpers/requests.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'server/helpers') diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts index fd2a56f30..d3c83d26e 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<GotOptions, 'headers' | 'json' | 'method' | 'searchParams'> @@ -92,6 +93,10 @@ const peertubeGot = got.extend({ path }, httpSignatureOptions) } + }, + + (options: GotOptions) => { + options.timeout = REQUEST_TIMEOUT } ] } @@ -182,6 +187,7 @@ function buildGotOptions (options: PeerTubeRequestOptions) { method: options.method, json: options.json, searchParams: options.searchParams, + timeout: options.timeout ?? REQUEST_TIMEOUT, headers, context } -- cgit v1.2.3