mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-10-27 12:02:59 -05:00
Automatically retry on temporary errors when using the presence API server
This commit is contained in:
@@ -441,6 +441,14 @@ function createApp(
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(JSON.stringify(response, replacer));
|
||||
} catch (err) {
|
||||
if (err && 'type' in err && 'code' in err && (err as any).type === 'system') {
|
||||
const code: string = (err as any).code;
|
||||
|
||||
if (code === 'ETIMEDOUT' || code === 'ENOTFOUND' || code === 'EAI_AGAIN') {
|
||||
res.setHeader('Retry-After', '60');
|
||||
}
|
||||
}
|
||||
|
||||
res.statusCode = 500;
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(JSON.stringify({
|
||||
|
||||
Reference in New Issue
Block a user