How to use event.waitUntil in denoflare? #9
-
I am currently trying to implement a small caching proxy on top of denoflare. The idea is to use Cloudflare Images as the origin and then use a Cloudflare worker for using their cache as it's a magnitude cheaper. I have finished most of the work and now I'm trying to port https://developers.cloudflare.com/workers/examples/cache-api to the scheme. I set up a small example here: https://github.com/survivejs/website-cf-assets/tree/feat/cache-images . See esp. the In the code I'm trying to port from, they have a line like this - Right now I'm getting the following error when trying to write to the cache just below the related line:
The interesting point is that the cloning related error is coming from Denoflare itself. I wonder if has something to do with the fact that I'm dealing with blobs here. Maybe there's some assumption that's biting. It would be great to hear how you would solve the problem using Denoflare as it seems like a good use case for it. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
In general, for module-based Cloudflare workers, a third argument Denoflare includes a type called I'm assuming you're trying to run this locally via I think the error you're receiving is cloning the response. Denoflare reimplements I can switch over and try and implement that stream init, how important is it to you to get running locally? For something simple like this, I would just |
Beta Was this translation helpful? Give feedback.
In general, for module-based Cloudflare workers, a third argument
context
is passed tofetch
, which has thewaitUntil
method. Module-based workers have noevent
.Denoflare includes a type called
ModuleWorkerContext
for this here with an explanation, but it is not Denoflare specific, just providing types for what Cloudflare already does.I'm assuming you're trying to run this locally via
denoflare serve
? It should implement that 3rd arg sowaitUntil
should work in general. Just pass it down from your fetch method.I think the error you're receiving is cloning the response. Denoflare reimplements
Response
when running locally, and supports cloning with an ArrayBuffer body, but not a stream …