When using CF Workers + JS, I was able
When using CF Workers + JS, I was able to stream large files out of a worker without hitting CPU limits via a ReadableStream. I'm now trying to do something similar via CF Workers + Rust and am having no such luck. As a shot in the dark, is there anything obvious that I'm doing wrong here?
Seeing
✘ [ERROR] Error: Worker exceeded CPU time limit.
2 Replies
For example, this JS-equivalent avoids the CPU timeout:
Okay, ChatGPT states that:
what actually happens under the hood is: 1. reqwest on WASM uses web_sys::ReadableStream to fetch the body, 2. bytes_stream() converts that into a Rust Stream<Item = Bytes> in WASM, 3. Response::from_stream immediately converts it back into a ReadableStream for the Worker runtime.It correctly points out that the following doesn't hit the CPU limits: I'm actually using
object_store
which uses reqwest
under the hood. Is there a way to make reqwest
streams work well wtih the worker response?
(I'm also going to look into seeing if I can swap out reqwest
for Fetch
in object_store
)Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View