feat: fail fast (timeout 12000 => 6000)

pull/65/head
Amio 2018-08-03 20:59:24 +08:00
rodzic e744c081d3
commit 506d06bedf
2 zmienionych plików z 5 dodań i 2 usunięć

Wyświetl plik

@ -1,7 +1,7 @@
const axios = require('axios')
module.exports = axios.create({
timeout: 12000,
timeout: 6000,
headers: {
'Accept': 'application/json'
}

Wyświetl plik

@ -27,7 +27,10 @@ async function fetchLiveParams (scope, fn, paramsPath) {
console.time(fetchKey)
waitings[fetchKey] = fn(...paramsPath.split('/')).catch(e => {
console.error(fetchKey, 'LIVE_ERROR', e.message)
return { failed: true }
return {
failed: true,
status: e.code === 'ECONNABORTED' ? 'timeout' : 'unknown'
}
}).then(result => {
console.timeEnd(fetchKey)
waitings[fetchKey] = undefined