kopia lustrzana https://github.com/badgen/badgen.net
feat: fail fast (timeout 12000 => 6000)
rodzic
e744c081d3
commit
506d06bedf
|
@ -1,7 +1,7 @@
|
||||||
const axios = require('axios')
|
const axios = require('axios')
|
||||||
|
|
||||||
module.exports = axios.create({
|
module.exports = axios.create({
|
||||||
timeout: 12000,
|
timeout: 6000,
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/json'
|
'Accept': 'application/json'
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,10 @@ async function fetchLiveParams (scope, fn, paramsPath) {
|
||||||
console.time(fetchKey)
|
console.time(fetchKey)
|
||||||
waitings[fetchKey] = fn(...paramsPath.split('/')).catch(e => {
|
waitings[fetchKey] = fn(...paramsPath.split('/')).catch(e => {
|
||||||
console.error(fetchKey, 'LIVE_ERROR', e.message)
|
console.error(fetchKey, 'LIVE_ERROR', e.message)
|
||||||
return { failed: true }
|
return {
|
||||||
|
failed: true,
|
||||||
|
status: e.code === 'ECONNABORTED' ? 'timeout' : 'unknown'
|
||||||
|
}
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
console.timeEnd(fetchKey)
|
console.timeEnd(fetchKey)
|
||||||
waitings[fetchKey] = undefined
|
waitings[fetchKey] = undefined
|
||||||
|
|
Ładowanie…
Reference in New Issue