diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-14 18:06:58 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-06-15 08:21:31 +0200 |
commit | 7500d6c9000b531fda1fd64e188b7cf83803941a (patch) | |
tree | 4329c72654b0d6526366cf47de588b7c7d72e073 /server/helpers/requests.ts | |
parent | 3d470a530c4a48b2e4f4a9e7d4f223e14f32cea4 (diff) | |
download | PeerTube-7500d6c9000b531fda1fd64e188b7cf83803941a.tar.gz PeerTube-7500d6c9000b531fda1fd64e188b7cf83803941a.tar.zst PeerTube-7500d6c9000b531fda1fd64e188b7cf83803941a.zip |
Use a global request timeout
Diffstat (limited to 'server/helpers/requests.ts')
-rw-r--r-- | server/helpers/requests.ts | 8 |
1 files changed, 7 insertions, 1 deletions
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' | |||
2 | import got, { CancelableRequest, Options as GotOptions, RequestError } from 'got' | 2 | import got, { CancelableRequest, Options as GotOptions, RequestError } from 'got' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { CONFIG } from '../initializers/config' | 4 | import { CONFIG } from '../initializers/config' |
5 | import { ACTIVITY_PUB, PEERTUBE_VERSION, WEBSERVER } from '../initializers/constants' | 5 | import { ACTIVITY_PUB, PEERTUBE_VERSION, REQUEST_TIMEOUT, WEBSERVER } from '../initializers/constants' |
6 | import { pipelinePromise } from './core-utils' | 6 | import { pipelinePromise } from './core-utils' |
7 | import { processImage } from './image-utils' | 7 | import { processImage } from './image-utils' |
8 | import { logger } from './logger' | 8 | import { logger } from './logger' |
@@ -24,6 +24,7 @@ type PeerTubeRequestOptions = { | |||
24 | key: string | 24 | key: string |
25 | headers: string[] | 25 | headers: string[] |
26 | } | 26 | } |
27 | timeout?: number | ||
27 | jsonResponse?: boolean | 28 | jsonResponse?: boolean |
28 | } & Pick<GotOptions, 'headers' | 'json' | 'method' | 'searchParams'> | 29 | } & Pick<GotOptions, 'headers' | 'json' | 'method' | 'searchParams'> |
29 | 30 | ||
@@ -92,6 +93,10 @@ const peertubeGot = got.extend({ | |||
92 | path | 93 | path |
93 | }, httpSignatureOptions) | 94 | }, httpSignatureOptions) |
94 | } | 95 | } |
96 | }, | ||
97 | |||
98 | (options: GotOptions) => { | ||
99 | options.timeout = REQUEST_TIMEOUT | ||
95 | } | 100 | } |
96 | ] | 101 | ] |
97 | } | 102 | } |
@@ -182,6 +187,7 @@ function buildGotOptions (options: PeerTubeRequestOptions) { | |||
182 | method: options.method, | 187 | method: options.method, |
183 | json: options.json, | 188 | json: options.json, |
184 | searchParams: options.searchParams, | 189 | searchParams: options.searchParams, |
190 | timeout: options.timeout ?? REQUEST_TIMEOUT, | ||
185 | headers, | 191 | headers, |
186 | context | 192 | context |
187 | } | 193 | } |