diff options
-rw-r--r-- | server/helpers/requests.ts | 7 | ||||
-rw-r--r-- | server/initializers/constants.ts | 9 | ||||
-rw-r--r-- | server/lib/activitypub/actors/webfinger.ts | 4 | ||||
-rw-r--r-- | server/lib/hls.ts | 2 |
4 files changed, 14 insertions, 8 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 | |||
3 | import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent' | 3 | import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent' |
4 | import { join } from 'path' | 4 | import { join } from 'path' |
5 | import { CONFIG } from '../initializers/config' | 5 | import { CONFIG } from '../initializers/config' |
6 | import { ACTIVITY_PUB, BINARY_CONTENT_TYPES, PEERTUBE_VERSION, REQUEST_TIMEOUT, WEBSERVER } from '../initializers/constants' | 6 | import { ACTIVITY_PUB, BINARY_CONTENT_TYPES, PEERTUBE_VERSION, REQUEST_TIMEOUTS, WEBSERVER } from '../initializers/constants' |
7 | import { pipelinePromise } from './core-utils' | 7 | import { pipelinePromise } from './core-utils' |
8 | import { processImage } from './image-utils' | 8 | import { processImage } from './image-utils' |
9 | import { logger, loggerTagsFactory } from './logger' | 9 | import { logger, loggerTagsFactory } from './logger' |
@@ -20,6 +20,7 @@ export interface PeerTubeRequestError extends Error { | |||
20 | } | 20 | } |
21 | 21 | ||
22 | type PeerTubeRequestOptions = { | 22 | type 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, |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index b65741bbd..b8633e83e 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -202,7 +202,12 @@ const JOB_PRIORITY = { | |||
202 | const BROADCAST_CONCURRENCY = 30 // How many requests in parallel we do in activitypub-http-broadcast job | 202 | const BROADCAST_CONCURRENCY = 30 // How many requests in parallel we do in activitypub-http-broadcast job |
203 | const AP_CLEANER_CONCURRENCY = 10 // How many requests in parallel we do in activitypub-cleaner job | 203 | const AP_CLEANER_CONCURRENCY = 10 // How many requests in parallel we do in activitypub-cleaner job |
204 | const CRAWL_REQUEST_CONCURRENCY = 1 // How many requests in parallel to fetch remote data (likes, shares...) | 204 | const CRAWL_REQUEST_CONCURRENCY = 1 // How many requests in parallel to fetch remote data (likes, shares...) |
205 | const REQUEST_TIMEOUT = 7000 // 7 seconds | 205 | const REQUEST_TIMEOUTS = { |
206 | DEFAULT: 7000, // 7 seconds | ||
207 | FILE: 30000, // 30 seconds | ||
208 | REDUNDANCY: JOB_TTL['video-redundancy'] | ||
209 | } | ||
210 | |||
206 | const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 // 2 days | 211 | const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 // 2 days |
207 | const VIDEO_IMPORT_TIMEOUT = 1000 * 3600 // 1 hour | 212 | const VIDEO_IMPORT_TIMEOUT = 1000 * 3600 // 1 hour |
208 | 213 | ||
@@ -896,7 +901,7 @@ export { | |||
896 | FFMPEG_NICE, | 901 | FFMPEG_NICE, |
897 | ABUSE_STATES, | 902 | ABUSE_STATES, |
898 | LRU_CACHE, | 903 | LRU_CACHE, |
899 | REQUEST_TIMEOUT, | 904 | REQUEST_TIMEOUTS, |
900 | USER_PASSWORD_RESET_LIFETIME, | 905 | USER_PASSWORD_RESET_LIFETIME, |
901 | USER_PASSWORD_CREATE_LIFETIME, | 906 | USER_PASSWORD_CREATE_LIFETIME, |
902 | MEMOIZE_TTL, | 907 | MEMOIZE_TTL, |
diff --git a/server/lib/activitypub/actors/webfinger.ts b/server/lib/activitypub/actors/webfinger.ts index 5532f05bd..b20a724da 100644 --- a/server/lib/activitypub/actors/webfinger.ts +++ b/server/lib/activitypub/actors/webfinger.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import WebFinger from 'webfinger.js' | 1 | import WebFinger from 'webfinger.js' |
2 | import { isProdInstance } from '@server/helpers/core-utils' | 2 | import { isProdInstance } from '@server/helpers/core-utils' |
3 | import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc' | 3 | import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc' |
4 | import { REQUEST_TIMEOUT, WEBSERVER } from '@server/initializers/constants' | 4 | import { REQUEST_TIMEOUTS, WEBSERVER } from '@server/initializers/constants' |
5 | import { ActorModel } from '@server/models/actor/actor' | 5 | import { ActorModel } from '@server/models/actor/actor' |
6 | import { MActorFull } from '@server/types/models' | 6 | import { MActorFull } from '@server/types/models' |
7 | import { WebFingerData } from '@shared/models' | 7 | import { WebFingerData } from '@shared/models' |
@@ -10,7 +10,7 @@ const webfinger = new WebFinger({ | |||
10 | webfist_fallback: false, | 10 | webfist_fallback: false, |
11 | tls_only: isProdInstance(), | 11 | tls_only: isProdInstance(), |
12 | uri_fallback: false, | 12 | uri_fallback: false, |
13 | request_timeout: REQUEST_TIMEOUT | 13 | request_timeout: REQUEST_TIMEOUTS.DEFAULT |
14 | }) | 14 | }) |
15 | 15 | ||
16 | async function loadActorUrlOrGetFromWebfinger (uriArg: string) { | 16 | async function loadActorUrlOrGetFromWebfinger (uriArg: string) { |
diff --git a/server/lib/hls.ts b/server/lib/hls.ts index d969549b8..3331e6272 100644 --- a/server/lib/hls.ts +++ b/server/lib/hls.ts | |||
@@ -130,7 +130,7 @@ function downloadPlaylistSegments (playlistUrl: string, destinationDir: string, | |||
130 | for (const fileUrl of fileUrls) { | 130 | for (const fileUrl of fileUrls) { |
131 | const destPath = join(tmpDirectory, basename(fileUrl)) | 131 | const destPath = join(tmpDirectory, basename(fileUrl)) |
132 | 132 | ||
133 | await doRequestAndSaveToFile(fileUrl, destPath, { bodyKBLimit: remainingBodyKBLimit }) | 133 | await doRequestAndSaveToFile(fileUrl, destPath, { bodyKBLimit: remainingBodyKBLimit, timeout: REQUEST_TIMEOUTS.FILE }) |
134 | 134 | ||
135 | const { size } = await stat(destPath) | 135 | const { size } = await stat(destPath) |
136 | remainingBodyKBLimit -= (size / 1000) | 136 | remainingBodyKBLimit -= (size / 1000) |