Cloudflare Developers

CD

Cloudflare Developers

Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news

Join

Incorrectly saying I have unpaid invoices when creating a new website.

I have an ongoing issue for over a month. When I try to add a new website and select the free plan, the following message appears in red in the notification toast popup. It is impossible to setup a new domain as a result. I have an open ticket with Cloudflare support, #01007138, however have received no response. You cannot add or modify subscriptions or services until all invoices are paid. Download each "Unpaid" invoice on your Billing page and click the "Pay online" link within each invoice to fix your account (Code: 1323)...

puzzling waitUntil warning

For the life of me, I'm not sure what part of my code is causing this. The result appears to be a handful of openai calls that are immediately failing, so I'm doing something wrong. I've bundled my async code into a single function which returns via return Promise.all(promises) to ctx.waitUntil() in my fetch. Running it locally (see screenshot) is also indecipherable....
No description

vite-tsconfig-paths throws error when used in Worker vitest config

Hello, I'm using custom paths inside of my tsconfig, I've tried to make Vitest compatible with them using the vite-tsconfig-paths plugin however it consistently gives me this error .. ``` āœ˜ [ERROR] "vite-tsconfig-paths" resolved to an ESM file. ESM file cannot be loaded by require`. See https://vitejs.dev/guide/troubleshooting.html#this-package-is-esm-only for more details. [plugin externalize-deps] ...

Access D1 database outside a request

Hello, I am trying to configure a D1 database for my Cloudflare worker. I have already created the database and added it to
wrangler.toml
wrangler.toml
. In the docs (https://developers.cloudflare.com/d1/get-started/), they say we can access the database like this: ``` export interface Env { // If you set another name in wrangler.toml as the value for 'binding',...

AWS SDK in Tail Worker?

Is it possible to use aws sdks in workers? I see Cloudflare have an example repo https://github.com/cloudflare/workers-aws-template/blob/master/index.js However, when I try to deploy my worker it fails due to the SDK requiring Node APIs under the hood (see screenshot)....
No description

I couldn't pay for workers from free plan

My website is getting reasonable traffic. Sometimes, the website is down, due to extensive requests. I tried purchasing the workers, showing 5$, but when I try to add card details and purchase, I am getting an error. Screenshot added. I have tried with multiple cards and the result is the same. Is it because I am having a free plan, restricting me from purchasing the workers?
No description

SSE - Server Sent Events

Is it possible to use server sent events in Cloudflare worker? If so, how does it work with the limit of 30 seconds per request? As my plan is to have a client listen to server sent events as long as they want.

New to workers, in workers I'm trying to get itty-router to work.

My structure looks like this src/index.js src/router/routes.js index.js...

'Global' Worker for Logging (alternative for logflare App)

Cloudflare is discontinuing "Apps" at the end of August. The only "App" I am using is logflare (global http request / response logging) - https://cloudflareapps.com/apps/logflare I've been looking into the best way to migrate to using Workers directly instead of "Apps". The issue I'm running into is, I have many existing Workers for my domain, on many different routes. The one nice thing about "Apps" was, they essentially were a "global" Worker that ran before any other worker in your zone. Because of this, logflare was able to "wrap" every request, including timing information, regardless of it went directly to Origin or through a Worker. I'm wondering if anyone has suggestions for the best way to reproduce this behavior with my own Worker? As I said, for routes without existing workers, it is fairly straightforward. I can just create a custom logflare worker, which runs on those unused routes. My only guess on how to "wrap" existing workers (so that the logging includes their response timing), is turn off routes for all existing workers, and instead have on single "global" worker that inspects the incoming request and then calls the associated existing worker if a route exists for them....

KV Put is not working have worker paid account

Also, I am having trouble using KV with Durable objects, I keep getting this error when using the put command
[wrangler:err] SyntaxError: Unexpected end of JSON input
[wrangler:err] SyntaxError: Unexpected end of JSON input
...

KV Namespace methods break when passed through constructor

Hey everyone, I'm trying to make my KV namespaces accessible in my services using dep injection with tsyringe. Is this something that is known to be unsupported? I found that after injecting the kv namespace the put() and get() methods seemingly blocks execution of anything coming after it, without any errors and no data being set or retrieved....

Fetch getting infinite 308 redirects in worker but fine locally

Hey, we are trying to make an external call from the worker. When testing the same code in wrangler dev mode, everything works fine, the same when running via curl in the command line, however as soon as it runs in production, the code fails with "Too many redirects." Upon inspection of this by checking the headers, the Location header returned is the exact URL that we are trying to send the request too, this continues in a loop until fetch errors out because of an infinite redirect loop. Again, this behaviour only shows up within workers, this doesn't happen from anywhere else. These responses also appear to be coming from cloudflare servers, when the request is targetted at an origin that is not proxied through cloudflare. Not sure how to debug this further...

Do RPCs work in localhost? šŸ¤”

Haven't been able to make them work and getting a The RPC receiver does not implement the method "sendTestEmail" error even though I have the 2 workers services running.

Cloudflare Worker for API endpoint returning Cloudflare error page

Under bursts of traffic some of my customers are seeing the Cloudflare error page instead of a response from my service. I don't see anything in the logs that would indicate an issue coming from the worker logic. Is my API endpoint getting throttled somehow? I'm on a paid plan which I assumed wasn't rate limited? It only seems to happen under bursts of traffic (relatively small bursts of less than 100). ...
No description

Create FixedLengthStream?

Probably a very basic question, but how do you create an instance of FixedLengthStream ? Created a new project via npx create-cloudflare@latest and just adding a simple line of:
const fls = new FixedLengthStream(8);
const fls = new FixedLengthStream(8);
...

Worker vitest push test file to R2

Hey, I am writing an implementation that utilises pre-uploaded files to R2. As part of this I want to write integration tests for this that can run locally with a test file. I was looking at having vitest push the file into the local R2 bucket before the tests run, but due to not having fs access I don't believe this is possible. Does anyone have any guidance on how I could go about doing this? The entire codebase relies on a single file existing in the bucket, which is uploaded in production as...

Error during browser scraping: Error: Unable to create new browser: code: 429: message: Too many bro

stack: Error: Unable to create new browser: code: 429: meā€¦raper/.wrangler/tmp/dev-X5LolW/index.js:13983:12), message: Unable to create new browser: code: 429: message: Too many browsers already running How do I check how many is running? How do I close it....

verify r2 upload using hash

I'm trying to implement a user file upload system with hash and size verification, along with streaming uploads to R2. The challenge I'm facing is that Workers have a 128MB memory limit, so I can't buffer the entire request. so I need to stream the upload to R2, but I'm struggling to find a way to cancel the upload if hash unmatched or size is not correct. Any suggestions on how to approach this would be really helpful. Thank you!...

Add file to R2 to test against

Hi all, I am trying to write tests for my code that uses Workers and R2. The problem that I am running into is that I need to use files to populate the R2 bucket and as data to test against. I have several files that I need to place into the R2 bucket before the tests run since the test storage is apparently isolated from the local bucket (which I can load files into easily with wrangler). Then I also need to load a couple JSON files that contain a sample of my expected data. Is there a way to accomplish either/both of these things? I have been reading documentation and forum posts all day do not feel any closer to a solution. Thanks in advance....

Is it possible to setup two workers that bind to each other?

Hi, I'm trying to setup a system with two separate workers: first one terminates a client WebSocket connection using a durable object and routes the WebSocket messages to another worker that provides data sync functionality for clients. The data-sync worker might also need to send replies periodically to clients connected via WebSocket to the first worker. I'm setting up service bindings based on this docs page: https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/#configuration Both workers expose an entrypoint class and accepts RPCs and routes them to DurableObjects. ...
No description