diff --git a/deezer/api.js b/deezer/api.js index 6b0b6df..a1ba2d1 100644 --- a/deezer/api.js +++ b/deezer/api.js @@ -49,8 +49,10 @@ class API{ }).json() } catch (e) { console.debug("[ERROR] deezer.api", method, args, e.name, e.message) - // await new Promise(r => setTimeout(r, 2000)) // sleep(2000ms) - // return this.api_call(method, args) + if (["ECONNABORTED", "ECONNREFUSED", "ECONNRESET", "ENETRESET", "ETIMEDOUT"].includes(e.code)){ + await new Promise(r => setTimeout(r, 2000)) // sleep(2000ms) + return this.api_call(method, args) + } throw new APIError(`${method} ${args}:: ${e.name}: ${e.message}`) } if (result_json.error){ diff --git a/deezer/gw.js b/deezer/gw.js index 2fcb09a..de8970c 100644 --- a/deezer/gw.js +++ b/deezer/gw.js @@ -64,8 +64,10 @@ class GW{ }).json() }catch (e){ console.debug("[ERROR] deezer.gw", method, args, e.name, e.message) - // await new Promise(r => setTimeout(r, 2000)) // sleep(2000ms) - // return this.api_call(method, args, params) + if (["ECONNABORTED", "ECONNREFUSED", "ECONNRESET", "ENETRESET", "ETIMEDOUT"].includes(e.code)){ + await new Promise(r => setTimeout(r, 2000)) // sleep(2000ms) + return this.api_call(method, args) + } throw new GWAPIError(`${method} ${args}:: ${e.name}: ${e.message}`) } if (result_json.error.length) throw new GWAPIError(result_json.error)