-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: “protocol not available” and “fetch failed” when running with Denoland and GOARCH=wasm go run but not with browser #39402
Comments
Is the |
Yes I believe so. Wondering if Node handles CORS differently to Chrome. Here's the
Essentially the same error I get using
|
NodeJS doesn't have Please confirm that |
Thanks - I will check that and get back to you. |
OK - So deno does include fetch but the network needs to be allowed. i.e.
So I tried patching the global object in node to include fetch. e.g.
This seemed to get things further, however its now causeing a panic. e.g.
So woking fine in the browser and using deno, but not NodeJS |
The line of this crash refers to the global go/src/net/http/roundtrip_js.go Line 80 in cd8f802
Seems like you need to set this, too. |
OK so I tried adding the following to my NodeJS code.
This gave me the same error using NodeJS. Interestingly, if I set this header in my Deno test script which does work without it, Deno then throws the same error. |
So I added the headers to the globals Then created a new Code is like this now:
|
If you're still getting the same error, it's still failing to instantiate the headers. Not sure what other help we can provide, you need to emulate the environment that exists in the browser. |
Thanks. I'll do some more research. There's obviously a difference between the Node & Deno runtimes, since Deno seems to handle things properly. |
Seems like there is nothing to fix for the Go project. Please reopen if necessary. |
Hi @carlskii, have you found a way to fix |
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
OutputWhat did you do?
I'm hitting a problem when using the
GOOS=js GOARCH=wasm go run -exec="$(go env GOROOT)/misc/wasm/go_js_wasm_exec" .
to test my WASM build via NodeJS which useswasm_exec.js
This is returning a
auth error: Post "https://server/authorize/": dial tcp: Protocol not available exit status 1
error.However, if test the same .wasm using
wasm_exec.html
it works perfectly, obviously in a browser. It also works if I compile to a normal go binary.I also used the following to test it using the Deno (https://deno.land/v1) toolchain:
This exposed a bit more information that relates to
fetch()
failing. i.e.net/http: fetch() failed: <object>
The text was updated successfully, but these errors were encountered: