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

Set Sentry environment with Cloudflare integration

Hey! I'm using cloudflare integration with sentry and I wonder how I can set environment?

Not able to get Logpush events

Hello, I was able to integrate Cloudflare Logpush into my axiom account, its been three days and I am not able to get worker dataset logpush events The test logs are coming successfully but the worker logs are not. These are the things that I have already verified...
No description

Why CF doesn't cache this worker?

Can someone help me figure out why this worker never gets cached: https://oparse.com/api/cache The response correctly sets cache-control max-age=60, stale-while-revalidate=60 (you can see it in the browser inspector)...

Importing Response and Request manually from @cloudflare/workers-types

Hi, I am integrating a workers AI project onto my monorepo project I am faced with this error in the fetch handler I tried various ways to fix it such as import type { Reques, Response } from "@cloudflare/workers-types"...
No description

Best way to handle external API rate limits globally

Hey I want to access an external api through my workers and it has a rate limit of 4 reqs a second, previously I used bottleneck and that worked great for me, but that doesn’t work in serverless environments and I’d prefer not to use redis. Is there a cloudflare option that helps manage this rate limit globally? Not just by region? I was looking at durable objects but just wanted to know if there was another way I was missing like maybe a nice package similar to bottleneck. Thanks!

Build custom rollout mechanism

Hi, I'm interested in building a custom rollout / versioning mechanism against the stored versions of workers. In pages, you are able to point to a specific version of the code at any given time since there is a deployment url for each build. I'm interested in doing something similar with Workers, given the worker versioning that was released more recently, but it seems that those versions aren't available at any time, they are only available if rolled back to. I'm wondering if I'm missing something, or if I'm correct in my analysis that the worker versions aren't currently available to be called at any given time?...

Build timeout at npm install?

Hey folks, I have a worker build that keeps timing out at the npm install step, does it really make sense that this take 20 mins? Is there anything I can do to debug?
No description

Websocket worker

I am trying to write a worker which handles websockets. I understand that Durable Objects are usually the more suitable solution for this, but I believe that this is the exceptional case. My use-case only involves single clients, without any multi-client coordination. My existing non-CF-worker codebase uses axum for the HTTP routing service. But, the axum ws flag pulls in a bunch of dependencies which do not build in WASM. Is there any strategy for getting websocket support in axum working on CF workers?...

I can't use fetch in workers

Hi, I'm having a problem with fetching external links, I'm using Worker and on site the fetch works for external links but when I deploy to Cloudflare, the fetch stops working That's my code ```ts interface Env {...

The response of a fetch() request in worker is different from same request in any other environment

I have a domain xolotto.com and subdomain blog.xolotto.com managed by Cloudflare. When I make a request from any browser https://blog.xolotto.com I have the response STATUS 200 OK and the content of the test page, which is expected. However when I make a fetch request to the same resource from the worker, the result of the fetch is STATUS 403 UNAUTHORIZED: export default {...

Websocket subprotocol results in Error: The script will never generate a response.

Websockets - sending subprotocols (auth token smuggling) results in Error: The script will never generate a response. Client:
const ws = new WebSocket(wsUrl, "potato");
const ws = new WebSocket(wsUrl, "potato");
...

Help debugging high CPU time in worker

Hey guys I really need some help to understand why I am seeing such a huge CPU time for a cloudflare worker. I am talking in the hundreds of ms which seems completely unexpected to me. I have attached a profiler from the worker that maybe someone with more experience in reading it can give me some hints because I've been studying it closely for some time and I feel like I am only extremely slowly inching closer to understanding. This worker is a queue consumer and producer. It produces recursively until enough tasks have been run. Basically all it does is async calls to an external api and db calls. One run of the queue handler would be around 10 fetches and ~40 db calls but in a transaction. I'm using kysely to access my db in a transaction and twisted to access the external api....

How can I add cron job to `wrangler.json` file?

I used svelitekit framework template and hosted to workers. I see this in my wrangler.json file: ```json "main": ".svelte-kit/cloudflare/_worker.js"...

Issue with esbuild + workers runtime, static method

The issue is that esbuild compiles some typescript into javascript, and then cloudflare is not able to handle the static built file. The error is ``` ✘ [ERROR] service core:user:silverkey: Uncaught TypeError: Object.defineProperty called on non-object...

How can I get a rate limiter working for my cloudfare workers proxy?

I recently made a roblox API proxy using cloudfare workers. I use the paid plan and my current concern is that if somebody were to get access to the link im sending requests from they could spam it which would result in my account being charged. How can I make sure theres a daily / monthly limit that it doesn't go over with requests? Thanks in advance!...

White label my app/service workers.

Hello there !! I am trying figure out if there a easy way to deploy clouldflare worker to mutiple prod env.. here are my use cases Web app that is deployed as A.com and B.com, each having it's own env vars.. pretty much as two separate apps....

Missing "cloudfare:email" npm package.

I'm trying to create an email worker using cloudfare docs but I'm unable to figure out what package I need to install. I've created a simple function for my pages app that would send an email but during deploymet I get the following error. Could not resolve "cloudfare:email ...

POST method is not working in fetch inside Queue Handler

Hono version: 4.6.20 Wrangler version: 3.107.2 I've tried a lot but fetch function inside queue is not executing in the worker both deployed version and local dev server. ...

Log push sends a single log line from an RPC service twice

Any console.log from this RPC stub gets sent twice to my log sink ``` class Payments extends RpcTarget { logger: Logger;...

Using local DO bindings from another worker script

I am trying to use DO bindings for local development but I am running into some issues. The docs (https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/#local-development) seem to indicate that you can bind two local workers by calling wrangler dev on each of them. But that is giving me an issue. My DO worker is defined like this: ``` export class DurableObjectClassName extends DurableObject<Env> {...
Next