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

Streaming in wasm doesn’t work #567

Open
irevoire opened this issue Apr 15, 2024 · 0 comments
Open

Streaming in wasm doesn’t work #567

irevoire opened this issue Apr 15, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@irevoire
Copy link
Member

Currently, when streaming documents in wasm, we actually collect everything in RAM before sending it:

// TODO: Currently reqwest doesn't support streaming data in wasm so we need to collect everything in RAM
#[cfg(not(target_arch = "wasm32"))]
{
let stream = ReaderStream::new(body);
let body = reqwest::Body::wrap_stream(stream);
request = request
.header(header::CONTENT_TYPE, content_type)
.body(body);
}
#[cfg(target_arch = "wasm32")]
{
use futures::{pin_mut, AsyncReadExt};
let mut buf = Vec::new();
pin_mut!(body);
body.read_to_end(&mut buf)
.await
.map_err(|err| Error::Other(Box::new(err)))?;
request = request.header(header::CONTENT_TYPE, content_type).body(buf);
}

This is because reqwest doesn’t provide the wrap_stream method, see: seanmonstar/reqwest#2248

@curquiza curquiza added the bug Something isn't working label Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants