From 279eddd689f85bbcd1a58669299f874178558321 Mon Sep 17 00:00:00 2001 From: A <258483684+la14-1@users.noreply.github.com> Date: Sat, 21 Feb 2026 08:46:25 -0800 Subject: [PATCH] fix: verify Node.js install after nodesource setup, add fallback (#1581) (#1592) The nodesource setup_22.x script can run successfully but leave nodejs uninstalled on Fly.io machines. Add post-install verification with `which node && node --version`, fall back to default Debian nodejs package if nodesource fails, increase timeout from 120s to 180s, and report a clear error if node is unavailable after all attempts. Agent: code-health Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 --- fly/lib/common.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/fly/lib/common.sh b/fly/lib/common.sh index 6af9a8b5..b7bccc7d 100644 --- a/fly/lib/common.sh +++ b/fly/lib/common.sh @@ -448,9 +448,19 @@ wait_for_cloud_init() { log_warn "Package install failed, continuing anyway..." } log_step "Installing Node.js..." - _fly_run_with_retry 3 10 120 "curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && apt-get install -y nodejs" || { - log_warn "Node.js install failed after retries, npm-based agents may not work" - } + _fly_run_with_retry 3 10 180 "curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && apt-get install -y nodejs" || true + # Verify node is actually installed — nodesource setup can succeed but leave node missing (#1581) + if ! run_server "which node && node --version" 15 >/dev/null 2>&1; then + log_warn "Node.js not found after nodesource install, falling back to default Debian package..." + _fly_run_with_retry 2 5 120 "apt-get install -y nodejs" || true + if ! run_server "which node && node --version" 15 >/dev/null 2>&1; then + log_error "Node.js is NOT installed — npm-based agents will not work" + else + log_info "Node.js installed from default Debian repos: $(run_server 'node --version' 10 2>/dev/null)" + fi + else + log_info "Node.js installed: $(run_server 'node --version' 10 2>/dev/null)" + fi log_step "Installing bun..." _fly_run_with_retry 2 5 120 "curl -fsSL https://bun.sh/install | bash" || true run_server 'echo "export PATH=\"\$HOME/.local/bin:\$HOME/.bun/bin:\$PATH\"" >> ~/.bashrc' 30 || true