net/http: roundtrip_js.go unusable in Node.js tests #31559
Comments
That is the catch here. |
I could be wrong but my impression is that this was just an assertion, not a question. I think the request here is that we make it possible to use the fetch wrapper while running a test. Unfortunately, before we can do that, we need #26051 finished, so we can reliably run the existing test under |
@johanbrandhorst is spot on, thanks for chiming in. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release? Yes.
What operating system and processor architecture are you using (
go env
)?go env
What did you do?
I wrote a test that requires a network request to
localhost
using thenet/http
library, compiled it to WASM and attempted to run it using Node.js. In order to get it to work in a Node.js environment, I add a shim forfetch
by requiring theisomorphic-fetch
NPM package.What did you expect to see?
I expected the request to complete without an error.
What did you see instead?
Digging into
roundtrip_js.go
, I found this check:Where
useFakeNetwork
is defined as:This logic means that any test making a network request that gets compiled to WASM is re-routed to a fake in-memory network. Non-WASM tests do not exhibit this behavior.
Is there any chance the core devs would consider making this behavior optional? Perhaps via an environment variable?
The text was updated successfully, but these errors were encountered: