aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
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
parentc5e53d0e3979c4602760e507a7240ea6ffad7823 (diff)
downloadPeerTube-4c99953acd04a2405db58ae2d7656a488bcc63a4.tar.gz
PeerTube-4c99953acd04a2405db58ae2d7656a488bcc63a4.tar.zst
PeerTube-4c99953acd04a2405db58ae2d7656a488bcc63a4.zip
Fix redundancy timeout
Diffstat (limited to 'server')
-rw-r--r--server/helpers/requests.ts7
-rw-r--r--server/initializers/constants.ts9
-rw-r--r--server/lib/activitypub/actors/webfinger.ts4
-rw-r--r--server/lib/hls.ts2
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
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,
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 = {
202const BROADCAST_CONCURRENCY = 30 // How many requests in parallel we do in activitypub-http-broadcast job 202const BROADCAST_CONCURRENCY = 30 // How many requests in parallel we do in activitypub-http-broadcast job
203const AP_CLEANER_CONCURRENCY = 10 // How many requests in parallel we do in activitypub-cleaner job 203const AP_CLEANER_CONCURRENCY = 10 // How many requests in parallel we do in activitypub-cleaner job
204const CRAWL_REQUEST_CONCURRENCY = 1 // How many requests in parallel to fetch remote data (likes, shares...) 204const CRAWL_REQUEST_CONCURRENCY = 1 // How many requests in parallel to fetch remote data (likes, shares...)
205const REQUEST_TIMEOUT = 7000 // 7 seconds 205const REQUEST_TIMEOUTS = {
206 DEFAULT: 7000, // 7 seconds
207 FILE: 30000, // 30 seconds
208 REDUNDANCY: JOB_TTL['video-redundancy']
209}
210
206const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 // 2 days 211const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 // 2 days
207const VIDEO_IMPORT_TIMEOUT = 1000 * 3600 // 1 hour 212const 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 @@
1import WebFinger from 'webfinger.js' 1import WebFinger from 'webfinger.js'
2import { isProdInstance } from '@server/helpers/core-utils' 2import { isProdInstance } from '@server/helpers/core-utils'
3import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc' 3import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc'
4import { REQUEST_TIMEOUT, WEBSERVER } from '@server/initializers/constants' 4import { REQUEST_TIMEOUTS, WEBSERVER } from '@server/initializers/constants'
5import { ActorModel } from '@server/models/actor/actor' 5import { ActorModel } from '@server/models/actor/actor'
6import { MActorFull } from '@server/types/models' 6import { MActorFull } from '@server/types/models'
7import { WebFingerData } from '@shared/models' 7import { 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
16async function loadActorUrlOrGetFromWebfinger (uriArg: string) { 16async 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)