https://discord.cloudflare.com logo
Join Discord
Powered by
# durable-objects
  • k

    kenton

    02/03/2023, 3:05 PM
    That sounds correct, yes. In fact,
    put()
    operations will almost always complete immediately. The promise returned by
    put()
    only exists to apply backpressure -- if you write too much stuff without taking a break, you risk exceeding your memory limit, in which case
    put()
    will start returning promises that pause for a bit. This promise actually will never indicate a failure (absent a bug in the runtime); instead, a failure resets the object before it has a chance to communicate with the rest of the world. So, any app which doesn't do excessive writes all at once can probably ignore the promise returned by
    put()
    entirely.
  • h

    HardAtWork

    02/03/2023, 4:48 PM
    Anyone know about what rps you can get with WebSockets in DOs?
  • a

    aa

    02/03/2023, 5:49 PM
    The docs for the newish sync() method on the transactional storage API says: > Synchronizes any pending writes to disk. But I am guessing actual behavior is that they are also replicated -- that is, this this promise doesn't resolve until the writes are durably stored in multiple locations. Can anyone confirm this?
  • a

    aa

    02/03/2023, 5:58 PM
    We have measured 8k/s 4kb messages outbound if DO is doing nothing else. Rate isn’t significantly affected by making messages smaller. It appears to be a per-write overhead, not per byte, probably because of the cost of underlying syscall.
  • a

    aa

    02/03/2023, 5:58 PM
    Have not measured inbound
  • t

    tim-clancy.eth

    02/03/2023, 5:59 PM
    Long time no post. 🙂 Can I call a Durable Object from another Durable Object? Having a hard time doing so using
    itty-router
    .
  • a

    aa

    02/03/2023, 6:02 PM
    Yes you can. We do this in our project.
  • a

    aranchelk

    02/03/2023, 6:02 PM
    Yes, you should just be able to create a stub and use fetch just as you would from a regular worker.
  • t

    tim-clancy.eth

    02/03/2023, 6:04 PM
    Cool, thanks. Must be an
    itty-router
    problem then. My environment in the entry Worker can find my DO stub, my environment within the DO cannot find the stub of the second DO.
  • a

    aranchelk

    02/03/2023, 6:07 PM
    Are you using itty-router inside the 1st DO?
  • t

    tim-clancy.eth

    02/03/2023, 6:07 PM
    Yeah
  • a

    aranchelk

    02/03/2023, 6:08 PM
    I'm not doing that, just itty in the main worker (entry point for the app).
  • t

    tim-clancy.eth

    02/03/2023, 6:09 PM
    Copy code
    js
    .post('/close', withParams, withContent, async (
          request, env
        ) => {
            const userId = env.User.idFromName(`user`);
            const user = env.User.get(userId);
    Cannot read properties of undefined (reading 'User')
  • a

    aranchelk

    02/03/2023, 6:09 PM
    Inside the DO, I get the env object from the constructor like this.
    Copy code
    constructor(state, env) {
                this.state = state
                this.env = env
  • t

    tim-clancy.eth

    02/03/2023, 6:10 PM
    Will try now.
  • t

    tim-clancy.eth

    02/03/2023, 6:11 PM
    Worked a charm. 🙂
  • t

    tim-clancy.eth

    02/03/2023, 6:12 PM
    Love this community, thanks a ton @aranchelk. Looks like the
    itty-router
    per-request environment variable does not carry the DO stubs within a DO but it does in the constructor. The per-request environment variable in a Worker does have the stubs.
  • a

    aranchelk

    02/03/2023, 6:13 PM
    You're welcome, no worries at all.
  • u

    0xcaff

    02/03/2023, 6:41 PM
    I just ran into this error. It doesn't seem to be documented anywhere in the docs and kinda breaks my use case. > Maximum number of keys modified in a transaction is 128. 😦
  • u

    0xcaff

    02/03/2023, 6:54 PM
    Curious, what constraint leads to this limit? Maybe something to do with the maximum size of updates when they're replicated to a 2nd fault domain? For my workload, I'm fine with loosing some writes as long as things are consistent (the entire transaction is either comitted or lost). It seems like it should be physically possible to remove this limit for transactions with allowUnconfirmed=true.
  • h

    HardAtWork

    02/03/2023, 8:10 PM
    Can the runtime collapse a WebSocket connection? As in, if a requests passes through three different Durable Objects, and then is returned with a WebSocket, is the WebSocket threaded through all three of those objects, or only from the client to the last object?
  • d

    DanTheGoodman

    02/03/2023, 8:17 PM
    Yielding to the
    fetch()
    handler
  • d

    DanTheGoodman

    02/03/2023, 8:18 PM
    And also I want to make sure all writes are coalesced, so I guess I can just await the last one?
  • d

    DanTheGoodman

    02/03/2023, 8:18 PM
    try
    new Date()
  • d

    DanTheGoodman

    02/03/2023, 8:18 PM
    I always use
    new Date().getTime()
  • h

    HardAtWork

    02/03/2023, 8:34 PM
    If that works, something is really borked, because this ```js new Date().getTime() === Date.now() ```should always be
    true
    ...
  • d

    DanTheGoodman

    02/03/2023, 8:35 PM
    lol idk, the docs say within a few ms but maybe the time you get is not real???
  • h

    HardAtWork

    02/03/2023, 8:38 PM
    It's always at least a few ms. behind, since the Timer is frozen
  • j

    john.spurlock

    02/03/2023, 8:41 PM
    for visibility/observability only, cloudflare analytics engine is really nice for this
  • j

    john.spurlock

    02/03/2023, 8:46 PM
    yes unfortunately it's a hard limit - agree that maybe putting that somewhere in the docs would be nice, it's only mentioned for individual calls, and like you said - it's a brick wall the first time you run into it in production
1...492493494...567Latest