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 <noreply@anthropic.com>
This commit is contained in:
A 2026-02-21 08:46:25 -08:00 committed by GitHub
parent 51493ccc75
commit 279eddd689
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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