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: support streaming request body in wasm #68698

Open
mihaiav opened this issue Aug 1, 2024 · 3 comments
Open

net/http: support streaming request body in wasm #68698

mihaiav opened this issue Aug 1, 2024 · 3 comments
Labels
arch-wasm WebAssembly issues NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@mihaiav
Copy link

mihaiav commented Aug 1, 2024

Go version

go1.22.5 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/mihai/Library/Caches/go-build'
GOENV='/Users/mihai/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/mihai/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/mihai/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.5'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/gs/rghtsvt5531bcqtkx6zlphc40000gn/T/go-build4222966030=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

I've tried to upload a large file (1.2 GB) to a remote server. Obviously I've posted the body as an io.Reader.

What did you see happen?

I've got an out of memory error:
runtime: out of memory: cannot allocate 918552576-byte block (3715989504 in use) [wasm_exec.js:22:14](https://hopz.com/static/wasm/wasm_exec.js) fatal error: out of memory

After some investigation I've found this line which seems to read the whole body before posting it.
https://github.com/golang/go/blob/master/src/net/http/roundtrip_js.go#L116

What did you expect to see?

I expected to be able to post large file using the io.Reader supported by the net/http package.

@mihaiav mihaiav changed the title net/http: POST body is read in memory before being posted net/http: POST body is read in memory causing fatal error or high memory usage Aug 1, 2024
@seankhliao seankhliao changed the title net/http: POST body is read in memory causing fatal error or high memory usage net/http: support streaming request body in wasm Aug 1, 2024
@seankhliao seankhliao added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. arch-wasm WebAssembly issues labels Aug 1, 2024
@seankhliao
Copy link
Member

this was previously implemented as CL 458395 and reverted for #61889

@ianlancetaylor
Copy link
Contributor

CC @golang/wasm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly issues NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants