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

Suddenly all our ctx.waitUntil workers are failing?

We have been using ctx.waitUntil for 2 years already with Cloudflare workers with the basic code sample below. This has always worked without any issues. Suddenly about an hour ago, all our workers with ctx.waitUntil fail with the following error message: "Can't read from request stream after response has been sent." This has never happend before and we haven't changed our code at all . Wondering if something is down with Workers? ctx.waitUntil(executeWebhookWait(request, env, pathName)); finalResponse = { success: true}; return new Response(JSON.stringify(finalResponse), { status: 200, headers: {...

How to define RPC methods on a separate file

I have an RPC method that is very long and thus don't want to define in the same place as other functions. I though about doing myFunction = myFunction but it complains that The RPC receiver does not implement the method "myFunction". Since myFunction uses this it's defined as: ```ts export async function myFunction( this: AuthWorker,...

Service binding config with the React template + local dev

I've been successfully using service bindings between back-end workers using the basic template and following the guidelines posted here: https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/rpc/ However, when using the React workers template, I can't seem to connect to service workers the same way when testing them locally. Do I need to configure them differently in wrangler.jsonc? (FYI each worker is in its own project/repo) The service binding entry in wrangler.jsonc is as follows:...

Create a New Worker Menu is Missing.

I recall using the "Create new Worker Menu" on the Workers & Pages > Overview page. Can anyone help me understand why I can't find this option anymore? Also, is there a way to create a new worker without using the template? Thank you!...
No description

R2 worker fails to put (some) files with error 10001

Since a couple of weeks back, our production R2 worker that we have been using without trouble for more than a year suddenly refuse to upload some files. In particular, TIFF files from some cameras seem to be consistently refused. The error message is "put: We encountered an internal error. Please try again. (10001)" Trying again most definitely does not help. It seems the exact files are the problem, since a lot of other files can still be uploaded....

defining custom domain in routes parameter in wrangler.jsonc impacts local host

Context: - I have added a custom domain as the top level param to wrangler.jsonc `"routes": [ { "pattern": "mydomain.com",...

RPC `Service<mysvc>` type doesn't have RPC method properties

I'm trying to declare my RPC service like so, but never get type safety on the RPC methods. ACCOUNTS_SERVICE: Service<import("@mymonorepo/services").AccountsService>; It errors with Property 'myMethod' does not exist on type '{ fetch(input: RequestInfo | URL, init?: RequestInit<CfProperties<unknown>> | undefined): Promise<Response>; connect(address: string | SocketAddress, options?: SocketOptions | undefined): Socket; }'.ts(2339) ...

R2.get() throws Unspecified error(0)

Hi, I have a Worker that gets a JSON file from R2. Sometimes, I get an error that says "Unspecified error (0)." There’s no other info in the logs. Has anyone else seen this when using R2 with Workers?

Worker Websocket TTL Cleanup

Hello! I'm looking to completely cleanup/delete a durable object once all connections are closed. I tried using an alarm following the exact same alarm code as the TTL example in the docs (https://developers.cloudflare.com/durable-objects/examples/durable-object-ttl/) minus the fetch part. Just defining a 10 minute alarm in the constructor and then an await this.ctx.deleteAll() in the alarm function. Somehow this just results in the alarm being continually triggered once every 10 minutes for all eternity. The alarm never stops, which tells me that the DO is never cleaned up. My current problem I'm trying to solve is to have a client start a long running async REST API call. This api call returns a transaction id which the webpage then listens to for updates using that specific transaction id (which is a durable object websocket server). The worker eventually has a callback invoked from an external server which lets it know the transaction is complete. This callback event is passed onto the durable object which publishes a message to websocket clients. Once the client receives this message (or the TTL is reached in the case that the callback is never invoked), the server should shutdown and the DO clean up....

Cache using fetch - cache TTL by response header

Hi, in https://developers.cloudflare.com/workers/examples/cache-using-fetch/ I can see there is cacheTtlByStatus property. Any way to achieve something likecacheTtlByResponseHeader equivalent where cache TTL will rely on the headers received from origin?...

Cloudflare D1 Database is not recognized as it inside a worker

Hello guys, I have created a worker which helps me to execute a cron which read data from a specific KV, and for each of those data make an API call and save the result into a database. The response saved match the following interface: ```...

Any way to get project code from workers deployed version

Hey guys by mistake I lost my project repo from my laptop and latest version was not on github too. But its running in workers. It was hono app deployed with workers. So is there any way to get the code from workers by any way.

Is there any way to deploy directly to my customer's CF account without using an API key?

Something like SSO? Background: I'm build a proprietary CF worker app and want to deploy it via wrangler directly to customer's account...

Can't create secrets or env variables?

I created a worker and deployed via wrangler and everything functions as expected. A colleague created another worker using the same mechanism, but for some reason we both get permissions errors when trying to create any secrets or variables for it. Nothing on the permissions side has changed. Is it possible there is a setting in the wrangler.toml I am missing?

Vite with WorkerEntrypoint (RPC)

I'm trying to run Hono app on Vite as Cloudflare Worker. I'm using @cloudflare/vite-plugin and I'm getting following error when vite serve: Worker "core:user:minerva-gateway"'s binding "AUTH_SERVICE" refers to a service "core:user:minerva-auth", but no such service is defined. The problem might be because I use WorkerEntrypoint (to enable RPC), does Vite support it? If so, where should I define the service?...

Issue with Workers / Nuxt / D1 via Drizzle

Hi, When I deploy my app to cloudflare workers, I get a 500 error when retrieving data from my database on initial load, if I use the refresh method to get the data again it works fine. Locally works fine on page load. This is how I am using drizzle:...

Shifting to workers from pages

We're looking into workers as an alternative to pages, and have a couple of compatibility questions - / 1. We have prod/preview env settings in pages, i cannot find the equivalent settings on workers. How do i set different env variables/secrets in prod/preview workers? 2. We get branch preview urls on pages, but for workers, it seems to change per commit. Is there a way to have a common branch deployment url for workers?...

Workers API responding very slow (>2 seconds for simple APIs, >20s for others)

I deployed a CF worker binded with a D1 database. I know about the cold start delay, but all my APIs are taking approx. 2 second each. I have an API to fetch 150 product data. That takes 20+ seconds. I optimized it to use batch queries and everything. I did EXPLAIN QUERY and the query itself takes 20ms. ...
No description

Workers-specific command in a Pages project

No matter how I try and deploy my project I keep getting stopped at the last step. I am using the GitHub integration and have set my CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN under Variables and Secrets in the Settings tab of my worker. I've also tried to check and it appears I am in a workers project NOT a pages one. But every time I build it goes through everything and then fails right at the end with a message that says something to the effect of 23:39:50.481 ✘ [ERROR] It looks like you've run a Workers-specific command in a Pages project. 23:39:50.482
23:39:50.482 For Pages, please run wrangler pages deploy instead....

Having Trouble Getting D1 to Work in Local Development with Drizzle ORM?

Everything works fine when I run drizzle migrate or use Drizzle Studio. Oddly enough, D1 also works perfectly after deploying to a Worker. However, it doesn't function in local development mode. For context, I'm using React Router v7 along with the Wrangler Vite plugin. Any ideas or suggestions would be greatly appreciated!...
No description