Skip to content

net/http: HTTP requests failing with 'Protocol not available' on wasm/js when running in browser #59605

Open
@rayvbr

Description

@rayvbr

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

$ go version
1.20.3

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
wasm/js

Chrome version: Version 111.0.5563.146 (Official Build) (x86_64)

(also reproducible with various Chromium-based browsers)

What did you do?

When doing a simple HTTP GET in a Go library compiled for wasm/js, all versions Go 1.18 and later are failing when running inside Chrome with dial tcp: lookup <some_domain>: Protocol not available.

When running on Go 1.17, this works fine. But Go 1.18 and later give the error above

The issue seems to be introduced by 2666262 and possibly made worse by 4c5d979. These commits seem to try to "autodetect" a Node environment by checking the presence of certain browser settings. While that may have been valid at time of committing, it seems the assumptions on which they were based no longer hold for more recent browser versions.

Perhaps a more direct/explicit way of checking whether we're running in a Node or browser environment would be more suitable? The methods above look a bit hacky

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-JSarch-wasmWebAssembly issues

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions