Skip to content

RFC: Support local extension downloading if remote downloading fails #298

Open
p12tic wants to merge 4 commits into
jeanp413:masterfrom
p12tic:support-download-fallback
Open

RFC: Support local extension downloading if remote downloading fails #298
p12tic wants to merge 4 commits into
jeanp413:masterfrom
p12tic:support-download-fallback

Conversation

@p12tic

@p12tic p12tic commented Jun 22, 2026

Copy link
Copy Markdown

Currently downloading extension remotely fails for any reason the remote workspace will fail to start up. In real VS Code this is implemented by local downloading fallback.

This PR implements a prototype in this extension. Currently tested on Linux only. Error handling is still to be improved. Best to be reviewed commit by commit.

Please let me know if this PR could be merged in principle. If yes, I will polish it and prepare for proper review.

Fixes: #38

Comment thread package.json
},
"remote.SSH.localServerDownload": {
"type": "string",
"description": "Controls whether the VS Code server binary is downloaded locally and transferred to the remote host via SFTP. 'auto' tries downloading on the remote first, then falls back to downloading locally and transferring via SFTP. 'always' always downloads locally and transfers via SFTP. 'never' only downloads directly on the remote machine.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/VS Code server binary/server binaries/ to make it more general and not directly referencing VS code?

@GitMensch GitMensch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The general approach looks fine to me, with the exception of duplicating part of the server startup script (deducing the server env).

In any case I think it would be best to tackle #287 first.

Comment thread src/serverSetup.ts
Comment on lines +2 to +4
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this much imports or isn't it reasonable to get it down to the actually used ones?

Comment thread src/serverSetup.ts
Comment on lines +138 to +176
let arch: string;
if (platform === 'windows') {
arch = 'x64';
} else {
const unameResult = await conn.exec('uname -m');
const remoteArch = unameResult.stdout.trim();
switch (remoteArch) {
case 'x86_64':
case 'amd64':
arch = 'x64';
break;
case 'armv7l':
case 'armv8l':
arch = 'armhf';
break;
case 'arm64':
case 'aarch64':
arch = 'arm64';
break;
case 'ppc64le':
arch = 'ppc64le';
break;
case 'riscv64':
arch = 'riscv64';
break;
case 'loongarch64':
arch = 'loong64';
break;
case 's390x':
arch = 's390x';
break;
default:
arch = remoteArch;
break;
}
}

return { platform: platform || 'linux', arch, shell };
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one seems to duplicate part of the code at

if ! command -v uname; then
- can we move that code out and use it in both cases? I think @daiyam was working/reviewing on moving the startup scripts out to a real file (easier to review/syntax-highlight/check, for example with ShellCheck) - maybe that part can be a separate script used from the new scripts and this piece of code?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, #287 need to came first. I will work on it in few days.

Comment thread src/serverSetup.ts
curl --retry 3 --connect-timeout 10 --location --show-error --silent --output vscode-server.tar.gz $SERVER_DOWNLOAD_URL
elif command -v fetch >/dev/null 2>&1; then
fetch --retry --timeout=10 --quiet --output=vscode-server.tar.gz $SERVER_DOWNLOAD_URL
if [[ -f vscode-server.tar.gz ]]; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would also use pre-located files there in general, no?
I think it is better to pass another arg (or as long as it is a contained script a replacement var) to decide which path to be used.

Comment thread src/serverSetup.ts
# Check if server script is already installed
if(!(Test-Path $SERVER_SCRIPT)) {
del vscode-server.tar.gz
if(Test-Path "vscode-server.tar.gz") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same applies as with the non-win32 script

@p12tic

p12tic commented Jun 30, 2026

Copy link
Copy Markdown
Author

Thank you for fast review. I will wait until #287 lands and then get back to this PR.

@daiyam

daiyam commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

@p12tic The scripts have been extracted ;)

@daiyam daiyam added this to the N+1 milestone Jul 1, 2026
@daiyam daiyam modified the milestones: v0.2.0, N+1 Jul 20, 2026
@daiyam

daiyam commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

@p12tic +1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add "remote.SSH.localServerDownload" setting

3 participants