Razzmatazz
Razzmatazz
CDCloudflare Developers
Created by Razzmatazz on 3/29/2024 in #workers-help
Unable to purge by URL in worker
I have a worker that periodically updates a JSON resource available via a URL. When the worker updates that resource, it uses the cloudflare API (https://api.cloudflare.com/client/v4/zones/[zone]/purge_cache) to purge it so the updated data is available. However, even though the API response indicates success, it is not actually purged. Using the API to purge the same URL works when done in Postman. What's going on here?
5 replies
CDCloudflare Developers
Created by Razzmatazz on 3/18/2024 in #workers-help
Caching POST requests works but shows warning in console
I'm using this guide to add caching of POST requests to my cloudflare worker: https://developers.cloudflare.com/workers/examples/cache-post-request/ It seems to work, but it's showing warnings in console. For the line that corresponds to const body = await request.clone().text();, it's showing the following error:
A ReadableStream branch was created but never consumed. Such branches can be created, for instance, by calling the tee() method on a ReadableStream, or by calling the clone() method on a Request or Response object. If a branch is created but never consumed, it can force the runtime to buffer the entire body of the stream in memory, which may cause the Worker to exceed its memory limit and be terminated. To avoid this, ensure that all branches created are consumed.

* Unused stream created
A ReadableStream branch was created but never consumed. Such branches can be created, for instance, by calling the tee() method on a ReadableStream, or by calling the clone() method on a Request or Response object. If a branch is created but never consumed, it can force the runtime to buffer the entire body of the stream in memory, which may cause the Worker to exceed its memory limit and be terminated. To avoid this, ensure that all branches created are consumed.

* Unused stream created
Anyone know how to get rid of this warning?
6 replies
CDCloudflare Developers
Created by Razzmatazz on 3/4/2024 in #workers-help
Sudden appearance of "Worker exceeded CPU time limit" errors
Previously-working workers being tested with wrangler dev --env development --remote started failing on Friday, and I can't figure out why. Our production workers appear to still be working fine, but testing workers with wrangler dev is not. The workers will respond to a few requests and then fail with X [ERROR] Error: Worker exceeded CPU time limit. errors. Once they fail with this error, they continue to fail for all requests until restarted. Bizarrely, if I pull from our main branch (which is deployed to production) and run wrangler dev, I still get these errors even though the worker is functioning just fine in production.
17 replies