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

In this case you could also use

In this case you could also use serializedAttachment on that particular WebSocket, assuming you haven't used up all the space with other stuff

closing old websocket server instances without errors

im trying to implement a ping pong logic combined with an ip rate limiter i created a Map() like so ```js // Retrieve or initialize ipInfo for this IP...

Getting tags associated with a Hibernatable WebSocket

Also, random question but if we support this.state.getTags(webSocket) for hibernatable websockets, would y'all want it to throw an error if you give it a non-hibernatable websocket? Or would you just want it to give you an empty array?

DO in rust, using (asyn) storage

Dont know anyone who uses rust for DOs that would be able to help but on javascript you run this.state.blockConcurrencyWhile(async () => { ... })

I'm working with Cloudflare Workers and

I'm working with Cloudflare Workers and Durable Objects (DO) and have a question about handling request forwarding. Specifically, I'm trying to understand the best way to forward request configurations such as the HTTP method, headers, and other details to a DO worker. Is there a specific API or method in Cloudflare Workers for directly forwarding these request configurations to a DO? Or do I need to manually extract these details from the incoming request, create a new request object with these values, and then pass this object to the DO?...

Sure -

Sure - The Durable Object handles websocket clients for a multiplayer game using a deterministic physics engine. The physics are executed on both the clients and the server. Serializing the physics world costs up to a few KB per player. To join games, I have a lobbies table in D1 with a game_state column: 'waiting' | 'playing' | 'finished'. I need to set the game to the finished state when it's abandoned, so if the player rejoins the websocket later, it won't re-initialize the DO. ...

@omar#4289 same as, I am getting the

@omar same as, I am getting the same issue, I have explained my issue
No description

hmm never had this happen personally

hmm never had this happen personally

OK I have read through the last three

OK, I have read through the last three months of discord and searched, and am still coming up empty. I am using itty-router-openapi to serve paths. I have only been getting KV pairs and that seems to work just fine in my worker. I would like to get a Durable Object called User: ```durable_objects.bindings = [...

I cannot figure out this typing error

I cannot figure out this typing error
No description

IIRC there is no way to launch a promise

IIRC there is no way to launch a promise in a durable object (from a request) in such a way that does not block a response? For example I am trying to ship logs from a custom logger async to loki, but i don't want that to block responding to a request

Hey I think someone is attacking our DOs

Hey I think someone is attacking our DOs:

```

``` const MINUTES = 60 * 1000 export class NanoID { constructor(state, env) {...

Yeah that will be the request it came

Yeah that will be the request it came from not the DO colo. Right now it is possible to do /cdn-cgi/trace, but there has been a discussion about that being removed so it wont be possible to tell.

Env separation

How do you do staging / production with durable objects? Do you have to have two classes e.g. ExampleClassStaging & ExampleClassProduction?

DO + pages

You need a second Worker, also running dev

That code base is really hard to follow

That code base is really hard to follow, can you be more specific on where the problem is?

I am trying to run a background promise

I am trying to run a background promise to drain logs in a durable object that looks like this: ``` const res = new Response("broadcasted") logger.Drain() return res...

TransactionalDOWrapper suggestions thread

Cool idea šŸ‘ ! I recommend checking out do-transactional-outbox for an even stronger model of storage consistency. For your example in the blog post, I'm not sure if by using awaitĀ you potentially eliminate (some of) the benefits of caching state in memory, let me explain. I recommend taking a look at state.blockConcurrencyWhile: call it in your constructor, no need to await it (you couldn't anyways, since constructors have to be sync), but it blocks further requests until you finish with your hydrate function. Then, you can always be sure that this.name and others will have been populated whenever your request comes in via fetch, so you can simplify your code further - eliminating another potential concurrency issue, where you're awaiting the hydrate promise, and another event handler starts executing, calling hydrate again, and potentially reading from storage once more as this.hydrated may not have been set to true yet (knock knock, race condition, who's there type situation), and then you overwrite name from the second call....

I have a question how the memory is

I have a question how the memory is managed for DO: Ā« If your account creates many instances of a single Durable Object class, Durable Objects may run in the same isolate on the same physical machine and share the 128 MB of memory. Ā» If we have 2 DO instances of the same class that running on the same colo, and share the same 128MB of memory. Imagine one currently uses 100MB and the other 27MB, then the second increase his memory usage and so we reach memory limit of the 128MB shared memory. What's happening? Is this second instance is killed and recreate automatically in exactly the same state on another 128MB VM of the colo ?...