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: use of request body in WASM Roundtripper panics #26349

Closed
johanbrandhorst opened this issue Jul 12, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@johanbrandhorst
Copy link
Member

commented Jul 12, 2018

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

tip

Does this issue reproduce with the latest release?

No, no WASM

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

linux amd64

What did you do?

I sent a request with a body in a binary compiled for WASM.

What did you expect to see?

The request would be sent successfully.

What did you see instead?

When using a request body with the new http.RoundTripper implemented for WASM, the call to set the body on the JavaScript fetch object panics.

Notes

Initially reported by John Marshall in https://groups.google.com/forum/#!topic/golang-nuts/7ZIU-YKoDVw. The bug was introduced with bafe466, a simple case of missing a use of a slice in roundtrip_js.go: https://github.com/golang/go/blob/master/src/net/http/roundtrip_js.go#L63.

@johanbrandhorst johanbrandhorst changed the title net/http: use of request body in WASM Roundtripped panics net/http: use of request body in WASM Roundtripper panics Jul 12, 2018

@johanbrandhorst

This comment has been minimized.

Copy link
Member Author

commented Jul 12, 2018

I will submit a fix for this.

johanbrandhorst added a commit to johanbrandhorst/go that referenced this issue Jul 12, 2018

net/http: correct use of byte slice in js syscall
syscall/js do not allow []byte to be used in direct inputs to
its JavaScript manipulation methods since
golang@bafe466.
Unfortunately, this use of a byte slice was missed, so any
uses of the WASM Roundtripper with a body will panic.
This ensures the byte slice is appropriately converted
before being passed to syscall.

Fixes golang#26349
@gopherbot

This comment has been minimized.

Copy link

commented Jul 12, 2018

Change https://golang.org/cl/123537 mentions this issue: net/http: correct use of byte slice in js syscall

@agnivade agnivade added this to the Go1.11 milestone Jul 12, 2018

johanbrandhorst added a commit to johanbrandhorst/go that referenced this issue Jul 12, 2018

net/http: correct use of byte slice in js syscall
syscall/js does not allow []byte to be used in direct inputs to
its JavaScript manipulation methods since
golang@bafe466.
Unfortunately, this use of a byte slice was missed, so any
uses of the WASM Roundtripper with a body will panic.
This ensures the byte slice is appropriately converted
before being passed to syscall.

Fixes golang#26349

johanbrandhorst added a commit to johanbrandhorst/go that referenced this issue Jul 12, 2018

net/http: correct use of byte slice in js syscall
syscall/js does not allow []byte to be used in direct inputs to
its JavaScript manipulation methods since
golang@bafe466.
Unfortunately, this use of a byte slice was missed, so any
uses of the WASM Roundtripper with a body will panic.
This ensures the byte slice is appropriately converted
before being passed to syscall.

Fixes golang#26349

@gopherbot gopherbot closed this in 28502b5 Jul 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.