Skip to content

SOCKS5 proxy: not working with Node.js webR #581

@HenrikBengtsson

Description

@HenrikBengtsson

I cannot get the SOCKS5 proxy approach presented in https://jeroen.github.io/notes/webassembly-curl/ to work when running webR via Node.js.

I've tried with both webr 0.5.5 and webr 0.5.6, and with Node 18, 20, and 22.

Reproducible examples

$ node webR-curl.mjs
Node.js v v22.19.0
webR v0.5.6
R v4.5.1

Downloading webR package: curl

curl v7.0.0

1. Testing with ALL_PROXY=‘’

[PASS] curl internet access: FALSE

2. Testing with ALL_PROXY=‘socks5h://test:yolo@ws.r-universe.dev:443’

Testing for internet connectivity via https_proxy... failed.
[FAIL] curl internet access: FALSE

where webR-curl.mjs is:

import { WebR } from "webr";
import WebSocket from "ws";

console.log('Node.js v', process.version);

// Launch webR instance
const webR = new WebR();
await webR.init();
console.log("webR v" + webR.version);

const code = [
    'message("R v", getRversion())',
    
    'webr::install("curl")',
    'message("curl v", packageVersion("curl"))',
    
    'Sys.unsetenv("ALL_PROXY")',
    'message("1. Testing with ALL_PROXY=", sQuote(Sys.getenv("ALL_PROXY")))',
    'ok <- curl::has_internet()',
    'message(if (ok) "[FAIL]" else "[PASS]", " curl internet access: ", ok)',
    
    'Sys.setenv(ALL_PROXY="socks5h://test:yolo@ws.r-universe.dev:443")',
    'message("2. Testing with ALL_PROXY=", sQuote(Sys.getenv("ALL_PROXY")))',
    'ok <- curl::has_internet()',
    'message(if (!ok) "[FAIL]" else "[PASS]", " curl internet access: ", ok)',
]

await webR.evalR(code);

process.exit(0);

Session information

$ node --version
v22.19.0
$ npm info webr

webr@0.5.6 | SEE LICENSE IN LICENCE.md | deps: 24 | versions: 28
The statistical programming language R compiled into WASM for use in a web browser and node.
https://github.com/r-wasm/webr

keywords: webR, wasm, R, statistics, programming, webassembly, emscripten

dist
.tarball: https://registry.npmjs.org/webr/-/webr-0.5.6.tgz
.shasum: de81b5738374e92fc19a4f32e2aa8273adb66fc1
.integrity: sha512-DYKJ95EDGu9bzJedOqn3Q9jZi/qvoWobUdJ+lnknXCTH8oDu9aXo/v6eeX9b9rpk08eqVzLS/9RdLNspF/QRmQ==
.unpackedSize: 49.3 MB

dependencies:
@codemirror/autocomplete: ^6.8.1  @msgpack/msgpack: ^2.8.0          codemirror-lang-r: ^0.1.0-2       lightningcss: ^1.21.5             react-data-grid: ^7.0.0-beta.44   react: ^18.2.0                    
@codemirror/commands: ^6.2.4      @xterm/addon-fit: ^0.10.0         codemirror: ^6.0.1                pako: ^2.1.0                      react-dom: ^18.2.0                tsx: ^4.0.0                       
@codemirror/state: ^6.2.1         @xterm/xterm: ^5.5.0              jszip: ^3.10.1                    prop-types: ^15.7.2               react-icons: ^4.10.1              xmlhttprequest-ssl: ^2.1.0        
@codemirror/view: ^6.15.0         classnames: ^2.2.6                lezer-r: ^0.1.1                   react-accessible-treeview: ^2.6.1 react-resizable-panels: ^2.0.19   xterm-readline: ^1.1.2            

maintainers:
- georgestagg <george.stagg@rstudio.com>

dist-tags:
latest: 0.5.6    next: 0.5.5-dev  

published a week ago by georgestagg <george.stagg@rstudio.com>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions