mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-06 03:50:26 +02:00
Use a global request timeout
This commit is contained in:
parent
3d470a530c
commit
7500d6c900
5 changed files with 12 additions and 12 deletions
|
@ -2,7 +2,7 @@ import { createWriteStream, remove } from 'fs-extra'
|
|||
import got, { CancelableRequest, Options as GotOptions, RequestError } from 'got'
|
||||
import { join } from 'path'
|
||||
import { CONFIG } from '../initializers/config'
|
||||
import { ACTIVITY_PUB, PEERTUBE_VERSION, WEBSERVER } from '../initializers/constants'
|
||||
import { ACTIVITY_PUB, PEERTUBE_VERSION, REQUEST_TIMEOUT, WEBSERVER } from '../initializers/constants'
|
||||
import { pipelinePromise } from './core-utils'
|
||||
import { processImage } from './image-utils'
|
||||
import { logger } from './logger'
|
||||
|
@ -24,6 +24,7 @@ type PeerTubeRequestOptions = {
|
|||
key: string
|
||||
headers: string[]
|
||||
}
|
||||
timeout?: number
|
||||
jsonResponse?: boolean
|
||||
} & Pick<GotOptions, 'headers' | 'json' | 'method' | 'searchParams'>
|
||||
|
||||
|
@ -92,6 +93,10 @@ const peertubeGot = got.extend({
|
|||
path
|
||||
}, httpSignatureOptions)
|
||||
}
|
||||
},
|
||||
|
||||
(options: GotOptions) => {
|
||||
options.timeout = REQUEST_TIMEOUT
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -182,6 +187,7 @@ function buildGotOptions (options: PeerTubeRequestOptions) {
|
|||
method: options.method,
|
||||
json: options.json,
|
||||
searchParams: options.searchParams,
|
||||
timeout: options.timeout ?? REQUEST_TIMEOUT,
|
||||
headers,
|
||||
context
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue