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/http: Fetch API-based Transport is accidentally disabled too widely #60808

Closed
dmitshur opened this issue Jun 15, 2023 · 1 comment
Closed
Labels
arch-wasm WebAssembly issues NeedsFix The path to resolution is known, but the work has not been done. OS-JS
Milestone

Comments

@dmitshur
Copy link
Contributor

During the Go 1.21 dev cycle, we updated from Node 14 to 18, which seems to provide the Fetch API, at least enough to cause it to be turned on during tests and not use the fake network. Since the HTTP server part is still implemented only as a fake network, that caused all tests/examples that start an HTTP server and send requests to it to fail. See #57613 for details.

Unfortunately the current implementation of jsFetchDisabled:

// jsFetchDisabled will be true if the "process" global is present.
// We use this as an indicator that we're running in Node.js. We
// want to disable the Fetch API in Node.js because it breaks
// our wasm tests. See https://go.dev/issue/57613 for more information.
var jsFetchDisabled = !js.Global().Get("process").IsUndefined()

Intersects poorly with wasm_exec.js that sets a "process" global whenever it's not already there:

globalThis.process = {
getuid() { return -1; },
getgid() { return -1; },
geteuid() { return -1; },
getegid() { return -1; },
getgroups() { throw enosys(); },
pid: -1,
ppid: -1,
umask() { throw enosys(); },
cwd() { throw enosys(); },
chdir() { throw enosys(); },
}

So it ends up inadvertently disabling Fetch API not only during testing as intended, but also in browsers that use an unmodified copy of wasm_exec.js.

CC @golang/js, @golang/wasm.

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. arch-wasm WebAssembly issues OS-JS labels Jun 15, 2023
@dmitshur dmitshur added this to the Go1.21 milestone Jun 15, 2023
@gopherbot
Copy link

Change https://go.dev/cl/503675 mentions this issue: net/http: only disable Fetch API in tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly issues NeedsFix The path to resolution is known, but the work has not been done. OS-JS
Projects
None yet
Development

No branches or pull requests

2 participants