Skip to content

Commit 5f89c4f

Browse files
authored
fix(connect): WS port preflight aborts under set -e when port is free (#70)
`preflight_ws_port` called `port_in_use "$p"; local rc=$?` as a bare statement. Under `set -euo pipefail`, `port_in_use` returns non-zero precisely when the port is FREE (its `grep -q` finds no listener), so `set -e` aborts the whole installer before `rc` is ever read — the common, healthy case silently kills the run right after the `ss | grep`. Capture the status in an errexit-exempt context so the rc=2 (no ss/netstat) / rc!=0 (free) / rc=0 (in use) branches work as intended: local rc=0; port_in_use "$p" || rc=$? Applied identically to all three env installers (mainnet-beta/devnet/testnet).
1 parent 806ccd6 commit 5f89c4f

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

scripts/connect-devnet.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ preflight_ws_port() {
427427
ws_disabled && return 0 # sink off -> nothing to bind
428428
local p; p="$(ws_port)"
429429
case "$p" in *[!0-9]*|'') return 0;; esac # not a plain numeric port -> let the bridge validate WS_BIND
430-
port_in_use "$p"; local rc=$?
430+
local rc=0; port_in_use "$p" || rc=$?
431431
if [ "$rc" -eq 2 ]; then
432432
warn "Can't check whether TCP port $p is free (no ss/netstat installed); if it's in use the WS sink won't bind (the tunnel is unaffected)."
433433
return 0

scripts/connect-testnet.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ preflight_ws_port() {
422422
ws_disabled && return 0 # sink off -> nothing to bind
423423
local p; p="$(ws_port)"
424424
case "$p" in *[!0-9]*|'') return 0;; esac # not a plain numeric port -> let the bridge validate WS_BIND
425-
port_in_use "$p"; local rc=$?
425+
local rc=0; port_in_use "$p" || rc=$?
426426
if [ "$rc" -eq 2 ]; then
427427
warn "Can't check whether TCP port $p is free (no ss/netstat installed); if it's in use the WS sink won't bind (the tunnel is unaffected)."
428428
return 0

scripts/connect.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ preflight_ws_port() {
422422
ws_disabled && return 0 # sink off -> nothing to bind
423423
local p; p="$(ws_port)"
424424
case "$p" in *[!0-9]*|'') return 0;; esac # not a plain numeric port -> let the bridge validate WS_BIND
425-
port_in_use "$p"; local rc=$?
425+
local rc=0; port_in_use "$p" || rc=$?
426426
if [ "$rc" -eq 2 ]; then
427427
warn "Can't check whether TCP port $p is free (no ss/netstat installed); if it's in use the WS sink won't bind (the tunnel is unaffected)."
428428
return 0

0 commit comments

Comments
 (0)