Add timeout to requests
This commit is contained in:
parent
0ca6a4a65e
commit
d8892e8875
|
@ -9,6 +9,7 @@ function doRequest <T> (
|
||||||
if (!(requestOptions.headers)) requestOptions.headers = {}
|
if (!(requestOptions.headers)) requestOptions.headers = {}
|
||||||
|
|
||||||
requestOptions.headers['User-Agent'] = `PeerTube search index (+${getWebserverUrl()})`
|
requestOptions.headers['User-Agent'] = `PeerTube search index (+${getWebserverUrl()})`
|
||||||
|
if (!requestOptions.timeout) requestOptions.timeout = 10000
|
||||||
|
|
||||||
return new Bluebird<{ response: request.RequestResponse, body: T }>((res, rej) => {
|
return new Bluebird<{ response: request.RequestResponse, body: T }>((res, rej) => {
|
||||||
request(requestOptions, (err, response, body) => err ? rej(err) : res({ response, body }))
|
request(requestOptions, (err, response, body) => err ? rej(err) : res({ response, body }))
|
||||||
|
|
Loading…
Reference in New Issue