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

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

Build Failed: error occurred while installing tools or dependencies

10:34:57.303 Initializing build environment... 10:35:04.164 Success: Finished initializing build environment 10:35:04.984 Cloning repository... 10:35:10.969 Detected the following tools from environment: [email protected], [email protected] 10:35:10.970 Installing nodejs 23.11.0...

wrangler.jsonc alternate "main" entrypoint in Vite Project

Hi, in a Vite React project deployed to Cloudflare Workers, created using pnpm create cloudflare@latest, I'm just curious if it's possible to set the "main" value in a project's wrangler.jsonc file to something other than the default "worker/index.ts" entrypoint. For example, if I want to setup a Hono API, can I change the entrypoint to "src/server/index.ts"? Logically, that feels doable, but is there anything else I need to do to keep Typescript happy and make sure my types generated by `work...

pnpm: EMFILE: too many open files

Hey everyone, I'm encountering an error while trying to build my monorepo project using Cloudflare Workers and the github integration. ``` 22:56:30.085 pnpm: EMFILE: too many open files, open '/opt/buildhome/repo/apps/server/node_modules/esbuild-register/package.yaml' 22:56:30.085 at async open (node:internal/fs/promises:638:25)...

Durable Objects Deployment Error

I expirience some issues in my CD (gh actions) with wrangler deployment of worker with durable objects. First deployment is always ok, but then any further updates fail with error:
Cannot apply new-sqlite-class migration to class 'BattleDurableObject' that is already depended on by existing Durable Objects
Cannot apply new-sqlite-class migration to class 'BattleDurableObject' that is already depended on by existing Durable Objects
i do not remove this migration form my wrangler.toml config. Docs say that for any further code updates of the DO executing wrangler deploy is sufficient. Have anyone faced this issue before? Also i am considering, if there are anything like local state based on which wrangler determines if it should run migrations or not?...

Missing `waitUntil` option -- what's that?

As per subject. I keep seeing that message in Workers Logs (I enabled observability) for my queues. My queue is running Browser Rendering

Build failing with ENOSPC: no space left on device for monorepo project on Cloudflare Workers Build.

Hi everyone, I'm encountering an error while trying to build my monorepo project using Cloudflare Workers Builds. The build process fails during the yarn install --production step with multiple "ENOSPC: no space left on device" errors. Build Command:...
Next