diff options
author | Julien Dessaux | 2023-05-30 22:19:49 +0200 |
---|---|---|
committer | Julien Dessaux | 2023-05-30 22:19:49 +0200 |
commit | 2828f62bc095e3413ac2ffbde4c338e2a00f1223 (patch) | |
tree | 77fc88932066df62a7aa12a854ad88e3cfcf8f06 | |
parent | Many new api calls (diff) | |
download | spacetraders-2828f62bc095e3413ac2ffbde4c338e2a00f1223.tar.gz spacetraders-2828f62bc095e3413ac2ffbde4c338e2a00f1223.tar.bz2 spacetraders-2828f62bc095e3413ac2ffbde4c338e2a00f1223.zip |
Retry on HTTP timeout instead of propagating the error
Diffstat (limited to '')
-rw-r--r-- | lib/api.js | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -68,7 +68,11 @@ function send_this(data) { return data.resolve(response);}) .catch(err => { fs.writeFileSync('log', JSON.stringify({event: 'error', date: new Date(), data: err}) + '\n', {flag: 'a+'}); - data.reject(err)}); + if (err.cause?.code === 'UND_ERR_CONNECT_TIMEOUT') { + send_this(data); + } else { + data.reject(err) + }}); setTimeout(send_next, 500); } |