Add timeout to requests
This commit is contained in:
parent
217666c707
commit
d13fd18641
|
@ -21,7 +21,9 @@ async function doRequestWithRetries<T> (
|
|||
msToWait: number,
|
||||
currentRetry = 0
|
||||
): Promise<{ response: request.RequestResponse, body: T }> {
|
||||
const res = await doRequest<T>(requestOptions)
|
||||
const updatedRequestOptions = Object.assign({}, requestOptions, { timeout: 10000 })
|
||||
|
||||
const res = await doRequest<T>(updatedRequestOptions)
|
||||
|
||||
if (res.response.statusCode === 429) {
|
||||
if (currentRetry < maxRetries) {
|
||||
|
|
|
@ -102,14 +102,18 @@ export class VideosIndexer extends AbstractScheduler {
|
|||
logger.info('Adding video data from %s.', host)
|
||||
|
||||
do {
|
||||
logger.debug('Getting results from %s (from = %d).', host, start)
|
||||
|
||||
videos = await getVideos(host, start)
|
||||
start += videos.length
|
||||
|
||||
logger.debug('Getting %d results from %s (from = %d).', videos.length, host, start)
|
||||
logger.debug('Got %d results from %s (from = %d).', videos.length, host, start)
|
||||
|
||||
if (videos.length !== 0) {
|
||||
const { created } = await indexVideos(videos)
|
||||
|
||||
logger.debug('Indexed %d videos from %s.', videos.length, host)
|
||||
|
||||
// Fetch complete video foreach created video (to get tags)
|
||||
for (const c of created) {
|
||||
this.scheduleVideoIndexation(host, c.uuid)
|
||||
|
|
Loading…
Reference in New Issue