Handle connection reset event
This commit is contained in:
parent
7008c91c6f
commit
d0ea2a12bc
1 changed files with 8 additions and 3 deletions
11
lib/api.js
11
lib/api.js
|
@ -68,12 +68,17 @@ 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+'});
|
||||
if (err.cause?.code === 'UND_ERR_CONNECT_TIMEOUT') {
|
||||
switch(err.cause?.code) {
|
||||
case 'ECONNRESET':
|
||||
send_this(data);
|
||||
} else {
|
||||
break;
|
||||
case 'UND_ERR_CONNECT_TIMEOUT':
|
||||
send_this(data);
|
||||
break;
|
||||
default:
|
||||
data.reject(err)
|
||||
}});
|
||||
setTimeout(send_next, 500);
|
||||
setTimeout(send_next, 400); // 333 should work, but 400 will still allow manual requests to go through during development
|
||||
}
|
||||
|
||||
export function debugLog(ctx) {
|
||||
|
|
Loading…
Add table
Reference in a new issue