Exit if proxy fails
Summary: If the proxy fails, exit. The proxy server is the one listening on the supplied TCP port, used by PWA. If it has failed, then quit the process. Reviewed By: aigoncharov Differential Revision: D47433631 fbshipit-source-id: 55750db5bf3e00876074a6b403747ec07718878c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ca009d1233
commit
f404827c69
@@ -206,13 +206,17 @@ async function startProxyServer(
|
|||||||
fs.rmSync(socketPath, {force: true});
|
fs.rmSync(socketPath, {force: true});
|
||||||
});
|
});
|
||||||
|
|
||||||
proxyServer?.on('error', (err, _req, res) => {
|
proxyServer?.on('error', (err, _req, _res) => {
|
||||||
console.warn('Error in proxy server:', err);
|
console.warn('Error in proxy server:', err);
|
||||||
if (res instanceof ServerResponse) {
|
|
||||||
res.writeHead(502, 'Failed to proxy request');
|
|
||||||
}
|
|
||||||
res.end('Failed to proxy request: ' + err);
|
|
||||||
tracker.track('server-proxy-error', {error: err.message});
|
tracker.track('server-proxy-error', {error: err.message});
|
||||||
|
|
||||||
|
// As it stands, if the proxy fails, which is the one
|
||||||
|
// listening on the supplied TCP port, then we should exit.
|
||||||
|
// Otherwise we risk staying in an invalid state, unable
|
||||||
|
// to recover, and thus preventing us to serve incoming requests.
|
||||||
|
// Bear in mind that exiting the process will trigger the exit hook
|
||||||
|
// defined above which will clean and close the sockets.
|
||||||
|
process.exit(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user