Keep worker running without request

I will be streaming files from S3/R2 to another service. I am planning to use worker for this scenario, since it has no bandwidth fee and any other cpu process usage. Is it possible to keep worker streaming files even after i cancel the 'fetch' request? In the docs it says, it can keep running at most 30 secs after fetch cancelled. I am pretty sure, 30 secs would be enough to deliver the files, since they are a few GBs at most.
3 Replies
Hello, I’m Allie!
Like this?
export default {
async fetch(req, env, ctx) {
// get object name/remote url somehow
ctx.waitUntil(fetch("https://another.service", {
method: "POST",
body: (await env.R2.get("object")).body()
}));
return new Response();
}
}
export default {
async fetch(req, env, ctx) {
// get object name/remote url somehow
ctx.waitUntil(fetch("https://another.service", {
method: "POST",
body: (await env.R2.get("object")).body()
}));
return new Response();
}
}
bajosi
bajosi2y ago
would this wait until fetch request is done, or would it stop the worker after 30 secs?
Hello, I’m Allie!
It would stop when you hit the CPU Limits for your plan, or the Worker is automatically evicted by the runtime.
Want results from more Discord servers?
Add your server