Open technosophos opened 3 years ago
/cc @fibonacci1729
Do you envisage asyncifying the call into the module, so that we can be returning the first bytes of the response as soon as the Wasm code produces them? Or are you just thinking of trying to reduce the copies between the stdout pipe, the buffer and the response body object?
Why did I think we would need to asyncify the call into the module? Well, we can't map stdout into a pipe that feeds directly into the response stream, because we need to do some processing on the beginning of the stream to convert top matter to headers. But I wonder if we could do that with some clever pipe/stream infrastructure so that it happens automatically as data is written to/read from the pipe.
https://github.com/bytecodealliance/wai-bindgen/pull/82 and streams should help with this.
Right now we buffer the entire HTTP payload before sending to the client. That is really bad performance for things like images. We should instead be able to send chunked data to the client.