Retry on HTTP timeout instead of propagating the error
This commit is contained in:
parent
d79a4485a6
commit
2828f62bc0
1 changed files with 5 additions and 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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue