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

OpenAI nodeJS library stopped working since last deploy about an hour ago

Our website relies heavily on OpenAI's Node.js library, since an hour ago, it seems there is a new constraint: (error) Error: Dynamic require of "node:util" is not supported. Is the only choice to rewrite everything using fetch();? ...

How to avoid cancel from client disconnection?

I’m trying to build a serverless chatbot for lark. Lark is an IM app like WhatApp. When someone sends a message to the bot account, it will send a POST request to an URL. I’m using worker as an intermediary to send the message to ChatGPT, and then send another POST request to send the reply to the chat. This should be two separate actions, but I’m currently putting the second into the first one to make them one worker. ...

websocket-upgrade fetch from worker to DO randomly delayed

We are using DOs for a registry that coordinates the running of multi-user web sessions. We have "synchronizer" nodes that are external to the registry, each maintaining long-lived websockets into the registry for its housekeeping tasks. A synchronizer watches for any of its socket connections dropping, or responding too sluggishly. In such cases, it automatically re-connects by sending a wss request to our ingress worker, whose fetch delegates to methods like this: ```function synchToSession(request: Request, env: Env, colo: string) {...

Worker reaches max CPU time but only when running integration test suite

I have a worker with the following setup. I am using node-postgres with node_compat = true in the wrangler.toml. I am using Supabase as my Postgres database and Drizzle as my ORM. I was using Turso before to just try it out, but would like to move to Supabase because the project includes file hosting and time series data which can all be handled by Supabase so it would simplify things. With Turso I was able to run the integration test suite with no issues and all tests were passing. But after moving to node-postgres, the first half of the tests pass, but about half way through workers starts erroring that the max CPU time was reached and the rest of the suite fails. Then if I re-run the tests without restarting the worker all the tests fail going forward. Another thing to note is I am doing some encryption and decryption stuff for some routes in this worker. But it is not for every route and wasn't causing issues before....

Caching example

https://developers.cloudflare.com/workers/examples/cache-post-request/ In this example, a POST request is cached. However, when there's a cache miss, we have the line response = await fetch(request) but isn't that just going to hit the worker again? I am trying to achieve something similar, but am looking for a way to encode the 'forwarding' url in my request, and wondering what the best way to do it is - query params, pathname, in the body or custom headers or something else?...

Uncaught Error: No such module " node:buffe

When I try to create a worker according to https://developers.cloudflare.com/workers/examples/signing-requests/ ,I get "Uncaught Error: No such module " node:buffer". imported from "worker.js" (Code: 10021)".

Workers timing out

Deploy timing out. Also reporting issue timinig. out. Does CF have a status page for all devlopment services? ...

I have problem about Update Cron Triggers on cloudflare API.

I've used the API to Update Cron Trigger on the following page. It had been working fine, but suddenly stopped working, even though I hadn't changed the code. https://developers.cloudflare.com/api/operations/worker-cron-trigger-update-cron-triggers ...

CORS Missing Allow Origin

I am havin problems with the Cors, the code I'm about to send here worked before, out of the blue it stopped working, is anyone able to help out? ```javascript if (request.method === 'OPTIONS') { // Handle CORS preflight req...

Configuring cors during development

In development I'm serving a JS app from a pages project and a local dev worker. since these are on different ports there's a XSS issue. I've configured CORS and can make the appropriate requests, but I can't access cookies returned from the worker in the JS frontend. I'm trying to establish a session cookie that is passed between subsequent POST requests from the frontend.

Remove/ignore lib.dom.d.ts

I've included the CF type definitions and have NOT explicitely included the DOM lib, but some other lib must be including it and subsequently the DOM types overrides (like Response.webSocket) are hidden and these references are showing up as errors. ``` src/email/mailbox-api.ts:33:25 - error TS2339: Property 'webSocket' does not exist on type 'Response'. ...

How to rate-limit and only allow request from specific origin for my worker?

Is it possible for my worker to only accept requests from my domain while also limiting the amount of requests people can do from that domain? In my case people can go to my website/domain and press buttons that fire events to my worker, now I want to prevent people from just spamming my worker till my costs explode. Is there any easy way to do this?

"ERR_RUNTIME_FAILURE" error when using `wrangler dev`

I get EPIPE error whenever I use wrangler command - Package Manager: bun - OS: macOS 15.0 dev beta 3...
No description

Reset workers subdomain

Is there a way to reset my account’s workers subdomain? We recently closed the business that the subdomain was designated for and we wanted to just reset it back to the default before customization. Is this possible and if so what’s the correct way to proceed?

Is Workers viable for running a function that takes minutes to complete?

I have a JavaScript function with Promise calls. It is responsible for running a Lighthouse-comparable feature called PageSpeed Insights API. It takes minutes before the function is executed because, just like a normal Lighthouse feature in the browser, it calculates metrics like performance and SEO for every website URL in the array I provide to the function. The problem is that it runs in the foreground of my Next.js app, preventing my users from clicking on any link, which would abort the whole process. The solution would be to ensure it runs in the background while users can still use my app. When the function is finished, a certain action should be performed on the Supabase database, and my Next.js app should know one way or another (perhaps using a webhook) that the function is finished. I am wondering if Workers might be a good fit to take that function? I remember that it is based on Edge so perhaps it might be troublesome for a worker to execute a function that takes couple of seconds to complete? I've tried to check the docs about Workers but I did not understand much....

Issue Integrating Stripe with Cloudflare Workers: Script will never generate a response

I’m encountering an issue while integrating Stripe into my Workers project. Everything works perfectly in my local environment, where I can create Stripe checkout sessions and access the billing portal through an API endpoint that returns the URL for Stripe checkout. However, upon deployment to Cloudflare, sometimes I receive an internal server error with the message that the script never generates a response and sometimes it just works. I’ve tried using both the Stripe SDK for Node.js and direct API calls, but both approaches result in the same error. Here are the code snippets I’ve used:...

Unable to setup prisma accelerate with cloudflare workers

index.ts ``` import { PrismaClient } from '@prisma/client/edge'; import { withAccelerate } from '@prisma/extension-accelerate'; export default {...

How to configure ratelimit on environment level?

Heya! I am trying to follow the documentation and setting up a rate limiter our worker. It seems that [[unsafe.binding]] does not work in top-level when [env] is being used:...

Are there TS types for rate limit function in @cloudflare/workers-types or other package?

I am implementing rate limiting and wondering if cloudflare ships types for this? Or should I create my own types temporarily?

logpush

Hi All, I just enabled logpush (account -level) for my worker. I can see the logs being pushed to r2 with extensions as .log.gz. On decompressing the file, the data is gibberish. It seems like the logs are encrypted but I can't seem to find any documentation related to it. Has anyone run into this issue?...