From 18db37810287218d306ff6bb5f646ed7cc2de8c6 Mon Sep 17 00:00:00 2001 From: Niels Mokkenstorm Date: Mon, 10 Aug 2026 17:33:31 +0200 Subject: [PATCH] fix: pick nc timeout flags that exist on the running platform --- scripts/dev.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/dev.sh b/scripts/dev.sh index 6fee513..66268f9 100755 --- a/scripts/dev.sh +++ b/scripts/dev.sh @@ -86,7 +86,15 @@ free_8080 # out with no hint as to why. The per-container `.orb.local` name resolves to # the default bridge instead, which is always routed, so it goes first, with # the inspected addresses as the fallback for other runtimes. -db_reachable() { nc -z -G 2 -w 2 "$1" 5432 >/dev/null 2>&1; } +# macOS nc needs -G to bound a connect to an unroutable host (-w alone hangs +# there); OpenBSD nc has no -G and bounds it with -w. Probe once rather than +# branching on uname, or every candidate reads as dead on the wrong platform. +if nc -G 1 -z 127.0.0.1 1 2>&1 | grep -q 'invalid option'; then + nc_timeout_flags="-w 2" +else + nc_timeout_flags="-G 2 -w 2" +fi +db_reachable() { nc -z $nc_timeout_flags "$1" 5432 >/dev/null 2>&1; } if [ -z "${DATABASE_URL:-}" ]; then db_cid="$(docker compose ps -q db 2>/dev/null | head -n1)" -- 2.51.2