Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote Extension Host: "The requested module 'node:module' does not provide an export named 'register'" on Linux #2049

Closed
2 tasks done
b-e-b-o-o opened this issue Oct 7, 2024 · 5 comments · Fixed by #2050
Labels
bug Something isn't working

Comments

@b-e-b-o-o
Copy link

b-e-b-o-o commented Oct 7, 2024

Describe the bug
When attempting to connect to a remote host, I get Error: Couldn't install vscode server on remote server, install script returned non-zero exit status.

This happened specifically using open-remote-ssh, which uses VSCodium's REH build. When manually downloading and attempting to execute bin/codium_server on the server, I get the error "The requested module 'node:module' does not provide an export named 'register'".

This only happens on the latest release build (1.94.0.24281), not the previous one. The Windows version of REH also works just fine.

IMPORTANT (for those reading who just want to use remote): A quick and simple workaround is as follows:

  1. Attempt to connect to the remote server (this installs vscodium-server)
  2. Stop all running instances of the bundled node on the server (eg. by running pkill -f ~/.vscodium-server/bin/*/node as the ssh user, or pkill -f .vscodium-server/bin/*/node as any user)
  3. Replace ~/.vscodium-server/bin/<commit>/node on the server with a newer version of the node binary, v18.20.4 works. Once again, ~ here means the home directory of the user you're using to connect with SSH.

Please confirm that this problem is VSCodium-specific

  • This bug doesn't happen if I use Microsoft's Visual Studio Code. It only happens in VSCodium.
    • The official stable server (downloaded by the Microsoft's Remote - SSH extension) uses node v20.16.0

Please confirm that the issue/resolution isn't already documented

To Reproduce
Steps to reproduce the behavior:

Download and extract vscodium-reh-linux-x64-1.94.0.24281.tar.gz on a Linux machine, and run bin/codium_server

Expected behavior
Remote host starts up and I'm able to connect without problems.

Logs

Server output:
SyntaxError: The requested module 'node:module' does not provide an export named 'register'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
    at async loadESM (node:internal/process/esm_loader:91:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12)
Install script:
[Trace  - 19:44:56.209] Server install command:

# Server installation script

TMP_DIR="${XDG_RUNTIME_DIR:-"/tmp"}"

DISTRO_VERSION="1.94.0"
DISTRO_COMMIT="e3ecc7b1f165b02bbce073afbe9ab016559e91cb"
DISTRO_QUALITY="stable"
DISTRO_VSCODIUM_RELEASE="24281"

SERVER_APP_NAME="codium-server"
SERVER_INITIAL_EXTENSIONS=""
SERVER_LISTEN_FLAG="--port=0"
SERVER_DATA_DIR="$HOME/.vscodium-server"
SERVER_DIR="$SERVER_DATA_DIR/bin/$DISTRO_COMMIT"
SERVER_SCRIPT="$SERVER_DIR/bin/$SERVER_APP_NAME"
SERVER_LOGFILE="$SERVER_DATA_DIR/.$DISTRO_COMMIT.log"
SERVER_PIDFILE="$SERVER_DATA_DIR/.$DISTRO_COMMIT.pid"
SERVER_TOKENFILE="$SERVER_DATA_DIR/.$DISTRO_COMMIT.token"
SERVER_ARCH=
SERVER_CONNECTION_TOKEN=
SERVER_DOWNLOAD_URL=

LISTENING_ON=
OS_RELEASE_ID=
ARCH=
PLATFORM=

# Mimic output from logs of remote-ssh extension
print_install_results_and_exit() {
    echo "485c0c35eb7d515dbfd18023: start"
    echo "exitCode==$1=="
    echo "listeningOn==$LISTENING_ON=="
    echo "connectionToken==$SERVER_CONNECTION_TOKEN=="
    echo "logFile==$SERVER_LOGFILE=="
    echo "osReleaseId==$OS_RELEASE_ID=="
    echo "arch==$ARCH=="
    echo "platform==$PLATFORM=="
    echo "tmpDir==$TMP_DIR=="
    
    echo "485c0c35eb7d515dbfd18023: end"
    exit 0
}

# Check if platform is supported
KERNEL="$(uname -s)"
case $KERNEL in
    Darwin)
        PLATFORM="darwin"
        ;;
    Linux)
        PLATFORM="linux"
        ;;
    FreeBSD)
        PLATFORM="freebsd"
        ;;
    DragonFly)
        PLATFORM="dragonfly"
        ;;
    *)
        echo "Error platform not supported: $KERNEL"
        print_install_results_and_exit 1
        ;;
esac

# Check machine architecture
ARCH="$(uname -m)"
case $ARCH in
    x86_64 | amd64)
        SERVER_ARCH="x64"
        ;;
    armv7l | armv8l)
        SERVER_ARCH="armhf"
        ;;
    arm64 | aarch64)
        SERVER_ARCH="arm64"
        ;;
    ppc64le)
        SERVER_ARCH="ppc64le"
        ;;
    riscv64)
        SERVER_ARCH="riscv64"
        ;;
    *)
        echo "Error architecture not supported: $ARCH"
        print_install_results_and_exit 1
        ;;
esac

# https://www.freedesktop.org/software/systemd/man/os-release.html
OS_RELEASE_ID="$(grep -i '^ID=' /etc/os-release 2>/dev/null | sed 's/^ID=//gi' | sed 's/"//g')"
if [[ -z $OS_RELEASE_ID ]]; then
    OS_RELEASE_ID="$(grep -i '^ID=' /usr/lib/os-release 2>/dev/null | sed 's/^ID=//gi' | sed 's/"//g')"
    if [[ -z $OS_RELEASE_ID ]]; then
        OS_RELEASE_ID="unknown"
    fi
fi

# Create installation folder
if [[ ! -d $SERVER_DIR ]]; then
    mkdir -p $SERVER_DIR
    if (( $? > 0 )); then
        echo "Error creating server install directory"
        print_install_results_and_exit 1
    fi
fi

SERVER_DOWNLOAD_URL="$(echo "https://github.com/VSCodium/vscodium/releases/download/\${version}.\${release}/vscodium-reh-\${os}-\${arch}-\${version}.\${release}.tar.gz" | sed "s/\${quality}/$DISTRO_QUALITY/g" | sed "s/\${version}/$DISTRO_VERSION/g" | sed "s/\${commit}/$DISTRO_COMMIT/g" | sed "s/\${os}/$PLATFORM/g" | sed "s/\${arch}/$SERVER_ARCH/g" | sed "s/\${release}/$DISTRO_VSCODIUM_RELEASE/g")"

# Check if server script is already installed
if [[ ! -f $SERVER_SCRIPT ]]; then
    if [[ "$PLATFORM" != "darwin" ]] && [[ "$PLATFORM" != "linux" ]]; then
        echo "Error "$PLATFORM" needs manual installation of remote extension host"
        print_install_results_and_exit 1
    fi

    pushd $SERVER_DIR > /dev/null

    if [[ ! -z $(which wget) ]]; then
        wget --tries=3 --timeout=10 --continue --no-verbose -O vscode-server.tar.gz $SERVER_DOWNLOAD_URL
    elif [[ ! -z $(which curl) ]]; then
        curl --retry 3 --connect-timeout 10 --location --show-error --silent --output vscode-server.tar.gz $SERVER_DOWNLOAD_URL
    else
        echo "Error no tool to download server binary"
        print_install_results_and_exit 1
    fi

    if (( $? > 0 )); then
        echo "Error downloading server from $SERVER_DOWNLOAD_URL"
        print_install_results_and_exit 1
    fi

    tar -xf vscode-server.tar.gz --strip-components 1
    if (( $? > 0 )); then
        echo "Error while extracting server contents"
        print_install_results_and_exit 1
    fi

    if [[ ! -f $SERVER_SCRIPT ]]; then
        echo "Error server contents are corrupted"
        print_install_results_and_exit 1
    fi

    rm -f vscode-server.tar.gz

    popd > /dev/null
else
    echo "Server script already installed in $SERVER_SCRIPT"
fi

# Try to find if server is already running
if [[ -f $SERVER_PIDFILE ]]; then
    SERVER_PID="$(cat $SERVER_PIDFILE)"
    SERVER_RUNNING_PROCESS="$(ps -o pid,args -p $SERVER_PID | grep $SERVER_SCRIPT)"
else
    SERVER_RUNNING_PROCESS="$(ps -o pid,args -A | grep $SERVER_SCRIPT | grep -v grep)"
fi

if [[ -z $SERVER_RUNNING_PROCESS ]]; then
    if [[ -f $SERVER_LOGFILE ]]; then
        rm $SERVER_LOGFILE
    fi
    if [[ -f $SERVER_TOKENFILE ]]; then
        rm $SERVER_TOKENFILE
    fi

    touch $SERVER_TOKENFILE
    chmod 600 $SERVER_TOKENFILE
    SERVER_CONNECTION_TOKEN="1f879f7f-e763-4f68-9ecd-aa43720df074"
    echo $SERVER_CONNECTION_TOKEN > $SERVER_TOKENFILE

    $SERVER_SCRIPT --start-server --host=127.0.0.1 $SERVER_LISTEN_FLAG $SERVER_INITIAL_EXTENSIONS --connection-token-file $SERVER_TOKENFILE --telemetry-level off --enable-remote-auto-shutdown --accept-server-license-terms &> $SERVER_LOGFILE &
    echo $! > $SERVER_PIDFILE
else
    echo "Server script is already running $SERVER_SCRIPT"
fi

if [[ -f $SERVER_TOKENFILE ]]; then
    SERVER_CONNECTION_TOKEN="$(cat $SERVER_TOKENFILE)"
else
    echo "Error server token file not found $SERVER_TOKENFILE"
    print_install_results_and_exit 1
fi

if [[ -f $SERVER_LOGFILE ]]; then
    for i in {1..5}; do
        LISTENING_ON="$(cat $SERVER_LOGFILE | grep -E 'Extension host agent listening on .+' | sed 's/Extension host agent listening on //')"
        if [[ -n $LISTENING_ON ]]; then
            break
        fi
        sleep 0.5
    done

    if [[ -z $LISTENING_ON ]]; then
        echo "Error server did not start sucessfully"
        print_install_results_and_exit 1
    fi
else
    echo "Error server log file not found $SERVER_LOGFILE"
    print_install_results_and_exit 1
fi

# Finish server setup
print_install_results_and_exit 0
Server install command stdout:
[Trace  - 19:44:58.796] Server install command stdout:
Server script already installed in /home/user/.vscodium-server/bin/e3ecc7b1f165b02bbce073afbe9ab016559e91cb/bin/codium-server
Error server did not start sucessfully
485c0c35eb7d515dbfd18023: start
exitCode==1==
listeningOn====
connectionToken==1f879f7f-e763-4f68-9ecd-aa43720df074==
logFile==/home/user/.vscodium-server/.e3ecc7b1f165b02bbce073afbe9ab016559e91cb.log==
osReleaseId==debian==
arch==x86_64==
platform==linux==
tmpDir==/run/user/1000==
485c0c35eb7d515dbfd18023: end

[Error  - 19:44:58.796] Error resolving authority
Error: Couldn't install vscode server on remote server, install script returned non-zero exit status
	at t.installCodeServer (c:\Users\beboo\.vscode-oss\extensions\jeanp413.open-remote-ssh-0.0.46-universal\out\extension.js:1:441139)
	at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
	at async c:\Users\beboo\.vscode-oss\extensions\jeanp413.open-remote-ssh-0.0.46-universal\out\extension.js:1:404879

Server:

  • OS: Debian GNU/Linux 12 (bookworm)
  • Architecture: x86-64
  • Version: 1.94.0.24281
  • Sandboxed: no
@b-e-b-o-o b-e-b-o-o added the bug Something isn't working label Oct 7, 2024
@daiyam
Copy link
Member

daiyam commented Oct 7, 2024

REH on linux is still using node-16 (for compatibility) which don't have the register function.

@entepe85
Copy link

entepe85 commented Oct 8, 2024

Remote terminals don't work any longer (using xaberus/remote-oss) after the described workaround, stating that the corresponding module was compiled against a different Node version.

@daiyam
Copy link
Member

daiyam commented Oct 8, 2024

I've added a known issue on release page of that version.
A new version with the fix should be out soon.

@daiyam
Copy link
Member

daiyam commented Oct 8, 2024

The fix has been merged and new release is going out.

I reopen the issue to you can validate if the issue is fixed on your end with the new version.

@daiyam daiyam reopened this Oct 8, 2024
@b-e-b-o-o
Copy link
Author

The fix has been merged and new release is going out.

I reopen the issue to you can validate if the issue is fixed on your end with the new version.

Thank you for your work, including this fast reply and fix! I cleaned the bin folder on the server, reconnected on the new version, and everything works as expected, using the bundled node v16:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants