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

Better error logging

Hi, I am trying to log the errors in a better way to include the stack trace on the logs. When I checked the docs, (https://developers.cloudflare.com/workers/observability/source-maps/), once source maps are enabled, we would see the trace with respect to the source maps. But after enabling, I am still seeing the trace with respect to the minified version (js). ...
No description

A unique URL and for each Workers build like Cloudflare Pages

I have a wrangler.toml file that has my name set to "website". I want to also have another worker, "website-staging" which is available on a different URL and I want that worker to build all branches. But my wrangler.toml is committed to github so it will always use that worker and overwrite my production worker. Any ideas on how I can set this up right? I feel like Cloudflare Pages had this figured out and would do a deployment to a unique URL for every build

Vitest monorepo service bindings and "The RPC receiver does not implement the method"

I have a monorepo that looks something like this: ``` /packages/api/{my hono server with Services bindings} /packages/services/...

Wrangler: blocked by CORS policy: The 'Access-Control-Allow-Origin' header

When testing locally via Wrangler, I get a CORS error for making a fetch to YouTube. in the client-side HTML page (in ./public/index.html NOT via Workers, but pure frontend). But when I use the the same HTML directly in the browser, it works as intended, with the results of the API call. I already added Access-Control-Allow-Origin: * in the ./public/_headers file....

Do Workers now have a preview environment?

Since pages is moving to workers, does that mean we can manage multiple workers environments (with variables/secrets) for both dev and prod projects like how pages exists now? I dont see this toggle in existing workers dashboard. But i do see preview urls (but im assuming thats just urls)....
No description

bundling static assets

I have some npm packages I use in both the worker, and in the html/js page I serve in the static assets. Is there any way to automatically bundle the html page so I can easily use the package there too?

Build error: too many open files

I am building a Next.js project on Cloudflare Workers, but I always get this error, could anyone help me? ``` 22:31:34.611 ... finished build of 7 collections and 106 documents in 1144ms 22:31:34.625 âš  No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache 22:31:34.630 Attention: Next.js now collects completely anonymous telemetry regarding usage....

Create worker from existing local repo

I'm looking for information on how to create a worker with c3 cli from my local nuxt repo that has git initialized ?

Dev vs Production deployment

According to the documentation, when creating a project with the Vue framework, it also creates an additional worker under server/index.js. I have written a worker that interacts with the D1 service in this file. When in development (npm run dev) the worker interacts with d1 without any problems. When deploying it to production (npm run deploy), the query function works as expected, but update function does not appear to be working. I have tried watching the logs and it appears to be exectuing the function as expected, but the database never reflects any of the updates Here is the fetch function that retrieves the data that works as expected: if (pathname === "/api/products") {...

Can't save, only deploy

In my workers, the option to save is usually grayed out, with the explanation (on hover) that I need to switch to modules format to enable saving, rather than only deploying -- but all of my workers are indeed using modules syntax. Is this a Cloudflare bug? Am I missing something obvious here? It would be nice to be able to save 😅...
No description

workers vs pages deployment

it's been a while since i last deployed something to CF pages but at that time CF was on the transition (i think) to merging workers and pages (and that pages will be deprecated at some point?) my question is where should i deploy my react app, it's a purely static react app and the backend is hosted on a VPS (similar to this https://github.com/benawad/how-to-roll-your-own-auth where although the frontend is in nextjs, it doesn't use next's buitin api routes) ...

Where is static-file hosting documented?

I have static files I want to host and the create-cloudflare script has an example for that, but in its wrangler.jsonc it doesn't include a main key which, according to the note in https://developers.cloudflare.com/workers/wrangler/configuration/#inheritable-keys is required. I'm assuming it's not required in this case because it's not a worker. But then, what is this exactly?...

SvelteKit front-end on CF Pages or CF Workers Assets?

Hi. I'm about to start a new project for my client, a new headless CMS + front-end. My usual stack contained SvelteKit on Cloudflare Pages, but reading about Workers Assets got me thinking about continuing with Pages or moving to Workers Assets. Many online comments (all unofficial) suggest that Workers Assets will push out Pages sooner or later. I would appreciate any guidelines on a subject. As the song goes - "Should I stay or should I go"? Cheers....

Questions About New Services Coming in June

Hey, we saw that the container service is set to launch in June and were wondering if there are any plans to roll out Cloud Build or Artifact Registry services around the same time. Could you let us know if these are coming soon or if there’s any info on when we can expect them?

Using Agent SDK to Support Long-Running SSE Connections

I'd like to experiment with Server Sent Events (SSE) and Datastar to serve up an interactive website using potentially long-running SSE connection streams. I've read about ways to game this in standard workers but there is a CPU-limit that can occur which requires a keep-alive signal on the stream to bypass and it's not "officially" supported (meaning, this might not be allowed moving forward). I notice that the Agent SDK specifically calls out support for long-running SSE connections as being supported: https://developers.cloudflare.com/agents/api-reference/http-sse/#implementing-server-sent-events...

Worker disconnects prematurely when consuming a stream from another worker via RPC

Hi, I have worker A that makes a call to worker B via RPC. Worker B returns a readable stream of bytes and worker A consumes the stream and uses the hono SSE function to stream back the chunks to the client. The client connects using EventSource. This works quite well with requests below 10 seconds. I have however a rather long task that can take between 1 to 3 minutes to complete and at some stage around 1 minute and half, worker A disconnects prematurely. This is the error I see Error: ReadableStream received over RPC disconnected prematurely. According to the cloudflare docs https://developers.cloudflare.com/workers/platform/limits/#duration there is no duration limit for workers. I am aware of the 30 seconds grace period on deployments but the incidence of that happening is rather low. Is there a time limit on streams over RPC or worker to worker connections?...

RR7 + Cloudflare

I have a simple hello world app created using RR7 and CF worker. I am trying to invoke a api endpoint ( hono ) from the loader function of react component. The app works fine when I run in local environment. But when I deploy to CF worker, the API endpoint invocation fails with error 404. Can someone please help me debug the issue. The code can be found here : https://github.com/bikash119/getting-started-v3...

How do we access production env vars and secrets with the vite-plugin?

I'm unable to read any env and the vite-plugin sidesteps writing the fetch where we can access. The docs are pretty minimal and never shows any example of consuming the env vars and secrets... https://developers.cloudflare.com/workers/vite-plugin/reference/secrets/...