fix: exit on EADDRINUSE instead of reusing port — prevents ghost instances with no tunnels
CI / Build & Test (push) Successful in 2m48s
CI / Build & Test (push) Successful in 2m48s
Made-with: Cursor
This commit is contained in:
@@ -125,11 +125,8 @@ function start(port, upstreamPort, callback) {
|
||||
|
||||
server.on('error', (err) => {
|
||||
if (err.code === 'EADDRINUSE') {
|
||||
stderrLog('port ' + connectPort + ' already in use — previous instance still running, reusing port');
|
||||
listenPort = connectPort;
|
||||
server.removeAllListeners('error');
|
||||
server.on('error', () => {});
|
||||
done(null);
|
||||
stderrLog('port ' + connectPort + ' already in use — another instance is running, exiting');
|
||||
process.exit(0);
|
||||
return;
|
||||
}
|
||||
stderrLog('server error:', err.message);
|
||||
|
||||
@@ -85,11 +85,8 @@ function start(port, certsDirOrCA, callback) {
|
||||
const listenPort = port || DEFAULT_PORT;
|
||||
proxyServer.on('error', (err) => {
|
||||
if (err.code === 'EADDRINUSE') {
|
||||
if (process.stderr) process.stderr.write('[https-proxy] port ' + listenPort + ' already in use — previous instance still running, reusing port\n');
|
||||
proxyPort = listenPort;
|
||||
proxyServer.removeAllListeners('error');
|
||||
proxyServer.on('error', () => {});
|
||||
done(null);
|
||||
if (process.stderr) process.stderr.write('[https-proxy] port ' + listenPort + ' already in use — another instance is running, exiting\n');
|
||||
process.exit(0);
|
||||
return;
|
||||
}
|
||||
if (process.stderr) process.stderr.write('[https-proxy] Error: ' + err.message + '\n');
|
||||
|
||||
Reference in New Issue
Block a user