aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/requests.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-11-29 15:45:02 +0100
committerChocobozzz <me@florianbigard.com>2021-11-29 15:45:02 +0100
commit4c99953acd04a2405db58ae2d7656a488bcc63a4 (patch)
treec2a35b969787729ec0013a8746493cdbca7b720b /server/helpers/requests.ts
parentc5e53d0e3979c4602760e507a7240ea6ffad7823 (diff)
downloadPeerTube-4c99953acd04a2405db58ae2d7656a488bcc63a4.tar.gz
PeerTube-4c99953acd04a2405db58ae2d7656a488bcc63a4.tar.zst
PeerTube-4c99953acd04a2405db58ae2d7656a488bcc63a4.zip
Fix redundancy timeout
Diffstat (limited to 'server/helpers/requests.ts')
-rw-r--r--server/helpers/requests.ts7
1 files changed, 4 insertions, 3 deletions
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
3import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent' 3import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent'
4import { join } from 'path' 4import { join } from 'path'
5import { CONFIG } from '../initializers/config' 5import { CONFIG } from '../initializers/config'
6import { ACTIVITY_PUB, BINARY_CONTENT_TYPES, PEERTUBE_VERSION, REQUEST_TIMEOUT, WEBSERVER } from '../initializers/constants' 6import { ACTIVITY_PUB, BINARY_CONTENT_TYPES, PEERTUBE_VERSION, REQUEST_TIMEOUTS, WEBSERVER } from '../initializers/constants'
7import { pipelinePromise } from './core-utils' 7import { pipelinePromise } from './core-utils'
8import { processImage } from './image-utils' 8import { processImage } from './image-utils'
9import { logger, loggerTagsFactory } from './logger' 9import { logger, loggerTagsFactory } from './logger'
@@ -20,6 +20,7 @@ export interface PeerTubeRequestError extends Error {
20} 20}
21 21
22type PeerTubeRequestOptions = { 22type PeerTubeRequestOptions = {
23 timeout?: number
23 activityPub?: boolean 24 activityPub?: boolean
24 bodyKBLimit?: number // 1MB 25 bodyKBLimit?: number // 1MB
25 httpSignature?: { 26 httpSignature?: {
@@ -129,7 +130,7 @@ async function doRequestAndSaveToFile (
129 destPath: string, 130 destPath: string,
130 options: PeerTubeRequestOptions = {} 131 options: PeerTubeRequestOptions = {}
131) { 132) {
132 const gotOptions = buildGotOptions(options) 133 const gotOptions = buildGotOptions({ ...options, timeout: options.timeout ?? REQUEST_TIMEOUTS.FILE })
133 134
134 const outFile = createWriteStream(destPath) 135 const outFile = createWriteStream(destPath)
135 136
@@ -235,7 +236,7 @@ function buildGotOptions (options: PeerTubeRequestOptions) {
235 return { 236 return {
236 method: options.method, 237 method: options.method,
237 dnsCache: true, 238 dnsCache: true,
238 timeout: REQUEST_TIMEOUT, 239 timeout: options.timeout ?? REQUEST_TIMEOUTS.DEFAULT,
239 json: options.json, 240 json: options.json,
240 searchParams: options.searchParams, 241 searchParams: options.searchParams,
241 retry: 2, 242 retry: 2,