From 506d06bedf566cb29e36f53b0aa467950dfa2468 Mon Sep 17 00:00:00 2001 From: Amio Date: Fri, 3 Aug 2018 20:59:24 +0800 Subject: [PATCH] feat: fail fast (timeout 12000 => 6000) --- libs/axios.js | 2 +- libs/live-badge-handlers.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/axios.js b/libs/axios.js index cae0bcb..d812f74 100644 --- a/libs/axios.js +++ b/libs/axios.js @@ -1,7 +1,7 @@ const axios = require('axios') module.exports = axios.create({ - timeout: 12000, + timeout: 6000, headers: { 'Accept': 'application/json' } diff --git a/libs/live-badge-handlers.js b/libs/live-badge-handlers.js index 971c37d..b179331 100644 --- a/libs/live-badge-handlers.js +++ b/libs/live-badge-handlers.js @@ -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