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

net: LookupHost Protocol not available on nodejs/wasm #60011

Open
tdegris opened this issue May 5, 2023 · 2 comments
Open

net: LookupHost Protocol not available on nodejs/wasm #60011

tdegris opened this issue May 5, 2023 · 2 comments
Labels
arch-wasm WebAssembly issues NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-JS

Comments

@tdegris
Copy link

tdegris commented May 5, 2023

What version of Go are you using (go version)?

$ go version
go version devel go1.21-fe10464358 Fri May 5 13:20:58 2023 +0000 linux/amd64

Does this issue reproduce with the latest release?

No. After doing a git bisect, I have:

4c5d97990e4a39bd3e903f8e318b7234db3ba91f is the first bad commit
commit 4c5d97990e4a39bd3e903f8e318b7234db3ba91f
Author: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Date:   Fri Jan 27 22:50:54 2023 -0800

    net/http: disable fetch on NodeJS

which is the first commit breaking http requests in WASM.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="..."
GOENV="..."
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="..."
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="..."
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="..."
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/.../go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.21-fe10464358 Fri May 5 13:20:58 2023 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3099992878=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Compile a WASM binary using:

GOOS=js GOARCH=wasm $GOROOT/bin/go build -o main.wasm main.go

then call from the WASM binary http.Client.Do which returns the following error:

http request error: Post "https://some.host/httpgrpc": dial tcp: lookup some.host: Protocol not available

What did you expect to see?

The http query to be executed.

What did you see instead?

An error saying that tcp is not available.

@seankhliao seankhliao changed the title http.Client.Do returns a protocol not supported error in WASM net: LookupHost Protocol not available on nodejs/wasm May 5, 2023
@seankhliao seankhliao added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. arch-wasm WebAssembly issues OS-JS labels May 5, 2023
@seankhliao
Copy link
Member

cc @golang/wasm

@sza-1
Copy link

sza-1 commented Jul 23, 2023

Just faced with same issue on go1.22-2eca0b1 and node v20.4.0. Some details are below.

gotip version
go version devel go1.22-2eca0b1 Fri Jul 21 21:37:46 2023 +0000 linux/amd64
node --version
v20.4.0

Go code (GOARCH=wasm and GOOS=js):

resp, err := http.Get("https://www.example.com")
log.Println(resp, err)

JavaScript/Node.js code:

import './wasm_exec.js';

const go = new Go();

go.run((await WebAssembly.instantiate(fs.readFileSync(process.argv[2]), go.importObject)).instance);

Output:

17:16:42.906000 h2_bundle.go:10048: http2: Transport failed to get client conn for www.example.com:443: http2: no cached connection was available
17:16:42.916000 main_js.go:144: <nil> Get "https://www.example.com": dial tcp: lookup www.example.com: Protocol not available

Current latest go1.20.6 in the same configuration works properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly issues NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-JS
Projects
None yet
Development

No branches or pull requests

3 participants