Handle etcd connection errors correctly in mon (unhandled error events)

hier-failure-domains
Vitaliy Filippov 2023-05-11 02:16:52 +03:00
parent ce4a8067b5
commit 6f4dc16c59
1 changed files with 3 additions and 0 deletions

View File

@ -1823,6 +1823,7 @@ function POST(url, body, timeout)
clearTimeout(timer_id);
let res_body = '';
res.setEncoding('utf8');
res.on('error', (error) => ok({ error }));
res.on('data', chunk => { res_body += chunk; });
res.on('end', () =>
{
@ -1842,6 +1843,8 @@ function POST(url, body, timeout)
}
});
});
req.on('error', (error) => ok({ error }));
req.on('close', () => ok({ error: new Error('Connection closed prematurely') }));
req.write(body_text);
req.end();
});