mirror of
				https://github.com/tailscale/tailscale.git
				synced 2025-11-04 02:01:14 +01:00 
			
		
		
		
	When running in our github CI environment, curl sometimes hangs while closing the download from the nodejs.org server and fails with INTERNAL_ERROR. This is likely caused by CI running behind some kind of load balancer or proxy that handles HTTP/2 incorrectly in some minor way, so force curl to use HTTP 1.1. Updates #8988 Signed-off-by: Val <valerie@tailscale.com>
		
			
				
	
	
		
			66 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			66 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/env bash
 | 
						|
# Run a command with our local node install, rather than any globally installed
 | 
						|
# instance.
 | 
						|
 | 
						|
set -euo pipefail
 | 
						|
 | 
						|
if [[ "${CI:-}" == "true" ]]; then
 | 
						|
    set -x
 | 
						|
fi
 | 
						|
 | 
						|
(
 | 
						|
    if [[ "${CI:-}" == "true" ]]; then
 | 
						|
        set -x
 | 
						|
    fi
 | 
						|
 | 
						|
    repo_root="${BASH_SOURCE%/*}/../"
 | 
						|
    cd "$repo_root"
 | 
						|
 | 
						|
    cachedir="$HOME/.cache/tailscale-node"
 | 
						|
    tarball="${cachedir}.tar.gz"
 | 
						|
 | 
						|
    read -r want_rev < "$(dirname "$0")/node.rev"
 | 
						|
 | 
						|
    got_rev=""
 | 
						|
    if [[ -x "${cachedir}/bin/node" ]]; then
 | 
						|
        got_rev=$("${cachedir}/bin/node" --version)
 | 
						|
        got_rev="${got_rev#v}" # trim the leading 'v'
 | 
						|
    fi
 | 
						|
 | 
						|
    if [[ "$want_rev" != "$got_rev" ]]; then
 | 
						|
        rm -rf "$cachedir" "$tarball"
 | 
						|
        if [[ -n "${IN_NIX_SHELL:-}" ]]; then
 | 
						|
            nix_node="$(which -a node | grep /nix/store | head -1)"
 | 
						|
            nix_node="${nix_node%/bin/node}"
 | 
						|
            nix_node_rev="${nix_node##*-}"
 | 
						|
            if [[ "$nix_node_rev" != "$want_rev" ]]; then
 | 
						|
                echo "Wrong node version in Nix, got $nix_node_rev want $want_rev" >&2
 | 
						|
		        exit 1
 | 
						|
            fi
 | 
						|
            ln -sf "$nix_node" "$cachedir"
 | 
						|
        else
 | 
						|
            # works for "linux" and "darwin"
 | 
						|
            OS=$(uname -s | tr A-Z a-z)
 | 
						|
            ARCH=$(uname -m)
 | 
						|
            if [ "$ARCH" = "x86_64" ]; then
 | 
						|
                ARCH="x64"
 | 
						|
            fi
 | 
						|
            if [ "$ARCH" = "aarch64" ]; then
 | 
						|
                ARCH="arm64"
 | 
						|
            fi
 | 
						|
            mkdir -p "$cachedir"
 | 
						|
	    # When running on GitHub in CI, the below curl sometimes fails with
 | 
						|
	    # INTERNAL_ERROR after finishing the download. The most common cause
 | 
						|
	    # of INTERNAL_ERROR is glitches in intermediate hosts handling of
 | 
						|
	    # HTTP/2 forwarding, so forcing HTTP 1.1 often fixes the issue. See
 | 
						|
	    # https://github.com/tailscale/tailscale/issues/8988
 | 
						|
            curl -f -L --http1.1 -o "$tarball" "https://nodejs.org/dist/v${want_rev}/node-v${want_rev}-${OS}-${ARCH}.tar.gz"
 | 
						|
            (cd "$cachedir" && tar --strip-components=1 -xf "$tarball")
 | 
						|
            rm -f "$tarball"
 | 
						|
        fi
 | 
						|
    fi
 | 
						|
)
 | 
						|
 | 
						|
export PATH="$HOME/.cache/tailscale-node/bin:$PATH"
 | 
						|
exec "$HOME/.cache/tailscale-node/bin/node" "$@"
 |