cloudflare / cloudflare/workers-rs

Example of how to get an output stream working?

Open
#209 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
3.7k
Forks
429
Avg merge
20h 28m
Merged PRs (30d)
7

Description

I have tried a number of different things in order to OUTPUT a stream, but I am getting no-where fast. It works perfectly on wrangler -dev, but fails on cloudflare with a "This script will never generate a response" error, which seems to occur right at the construction of the wrapper itself (before its even returned.

Some examples I have tried:

```rs
console_log!("this log is visible");
let rs = wasm_streams::ReadableStream::from_stream(ss);
console_log!("it never gets to here, throwing 'Error: the script will never generate a response'");
let sss = rs.into_raw().dyn_into().expect("an error, never hit");
console_log!("never hit");
let mut rb = ResponseBody::Stream(sss);
console_log!("never hit");
let mut headers = Headers::new();
headers.append("Content-Type", "image/jpeg");
return Ok(Response::from_body(rb)?.with_headers(headers));
```

```rs
console_log!("this log is visible");
let mut headers = Headers::new();
headers.append("Content-Type", "image/jpeg");
console_log!("this is also visible");
let mut rx = Response::from_stream(s)?.with_headers(headers);
console_log!("this is never hit. The script will never generate a response");
return Ok(rx);
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.