From 4c99953acd04a2405db58ae2d7656a488bcc63a4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 29 Nov 2021 15:45:02 +0100 Subject: Fix redundancy timeout --- server/helpers/requests.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'server/helpers/requests.ts') diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts index fc77ebd35..327610558 100644 --- a/server/helpers/requests.ts +++ b/server/helpers/requests.ts @@ -3,7 +3,7 @@ import got, { CancelableRequest, NormalizedOptions, Options as GotOptions, Reque import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent' import { join } from 'path' import { CONFIG } from '../initializers/config' -import { ACTIVITY_PUB, BINARY_CONTENT_TYPES, PEERTUBE_VERSION, REQUEST_TIMEOUT, WEBSERVER } from '../initializers/constants' +import { ACTIVITY_PUB, BINARY_CONTENT_TYPES, PEERTUBE_VERSION, REQUEST_TIMEOUTS, WEBSERVER } from '../initializers/constants' import { pipelinePromise } from './core-utils' import { processImage } from './image-utils' import { logger, loggerTagsFactory } from './logger' @@ -20,6 +20,7 @@ export interface PeerTubeRequestError extends Error { } type PeerTubeRequestOptions = { + timeout?: number activityPub?: boolean bodyKBLimit?: number // 1MB httpSignature?: { @@ -129,7 +130,7 @@ async function doRequestAndSaveToFile ( destPath: string, options: PeerTubeRequestOptions = {} ) { - const gotOptions = buildGotOptions(options) + const gotOptions = buildGotOptions({ ...options, timeout: options.timeout ?? REQUEST_TIMEOUTS.FILE }) const outFile = createWriteStream(destPath) @@ -235,7 +236,7 @@ function buildGotOptions (options: PeerTubeRequestOptions) { return { method: options.method, dnsCache: true, - timeout: REQUEST_TIMEOUT, + timeout: options.timeout ?? REQUEST_TIMEOUTS.DEFAULT, json: options.json, searchParams: options.searchParams, retry: 2, -- cgit v1.2.3