fix: exit on EADDRINUSE instead of reusing port — prevents ghost instances with no tunnels
CI / Build & Test (push) Successful in 2m48s

Made-with: Cursor
This commit is contained in:
Raven Scott
2026-02-27 19:57:47 -05:00
parent b0b17e26df
commit 78e6af39f5
2 changed files with 4 additions and 10 deletions
+2 -5
View File
@@ -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);
+2 -5
View File
@@ -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');