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

    sathoro

    05/02/2023, 5:05 PM
    it just started an infinite loop when starting the dev server 🤣
  • s

    sathoro

    05/02/2023, 5:07 PM
    doesn't seem possible unless there is another way to specify the binding
  • s

    Skye

    05/02/2023, 5:52 PM
    Oh it's possible it's broken in local dev lol, that's not a common use case
  • s

    Skye

    05/02/2023, 5:52 PM
    I'd recommend you just import your normal fetch method, since they're in the same codebase, and use that
  • s

    sathoro

    05/02/2023, 5:55 PM
    hmm it kicks off a long running process in the worker inside a waitUntil. I think this could cause trouble when running inside the DO
  • s

    Skye

    05/02/2023, 5:56 PM
    Ah that could be a problem, yes
  • s

    Skye

    05/02/2023, 5:56 PM
    Doing a normal fetch is probably your best bet then
  • s

    sathoro

    05/02/2023, 7:15 PM
    can you call another durable object from inside a different durable object? I'm receiving a weird miniflare error
  • s

    sathoro

    05/02/2023, 7:16 PM
    [mf:err] Unhandled Promise Rejection: TypeError: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received null
    but I am not passing
    null
    . I even hardcoded a string just to make sure
  • c

    ckoeninger

    05/02/2023, 7:26 PM
    Yes you can call a durable object from inside a different durable object. Have you tried publishing it, or just miniflare?
  • s

    sathoro

    05/02/2023, 7:27 PM
    nevermind, sorry, I'm not sure what was happening there but it is working now
  • s

    stochastic

    05/02/2023, 9:21 PM
    Is there any way for a DurableObject to know it's migration number or deployment id at run time?
  • c

    ckoeninger

    05/02/2023, 9:36 PM
    what are you trying to accomplish?
  • s

    stochastic

    05/02/2023, 9:45 PM
    The durable objects store event history and may need to recalculate a snapshot of state if their code changes.
  • s

    stochastic

    05/02/2023, 9:46 PM
    Current deployment id would be fine, but it doesn't seem like its available
  • c

    ckoeninger

    05/02/2023, 9:55 PM
    I guess I'm not understanding - when you update code, running DOs are going to be removed from memory and the constructor in the new code is going to run for new requests. What decision will that constructor make based on deployment id that it couldn't make based on stored data (or on constants in the code itself)?
  • s

    stochastic

    05/02/2023, 9:57 PM
    The durable object stores computed state to save time. If the algorithm is ever updated we may need to recompute state.
  • s

    stochastic

    05/02/2023, 9:58 PM
    This is an application level thing not an infra/ops thing.
  • s

    stochastic

    05/02/2023, 9:59 PM
    I was going to use the deployment or migration id as a flag to let the do it should throw away it's old stored state and instead recompute and store a snapshot of that. It can be quite expensive in some cases.
  • v

    Volkan

    05/02/2023, 10:29 PM
    Hello y'all. Newbie here. I wanted to check in to see if anyone has some time to discuss how to build the architecture for a simple word game; using Durable Objects, and Websockets on Cloudflare Workers (obvi).
    • 1
    • 3
  • c

    ckoeninger

    05/02/2023, 10:45 PM
    If it's not obvious from the stored state that it needs to be recomputed, you're going to have to put something in storage that indicates what version it was computed with. Deployment id, even if you had access to it, seems less convenient than a constant for version in the code that you increment only for code updates that require recomputation.
  • s

    stochastic

    05/03/2023, 3:30 AM
    Gave it some more thought and this is the more prudent option.
  • s

    steeldragon

    05/03/2023, 4:41 PM
    Does every durable object invocation get its own subrequest limit?
  • d

    Dani Foldi

    05/03/2023, 4:42 PM
    yes, and when it starts handling a new request it's reset to 1000
  • s

    steeldragon

    05/03/2023, 4:42 PM
    example: DO instance 1 wakes up from an alarm call and does 10 KV gets, it then calls a second DO instance, how many KV gets can the second instance do?
  • s

    steeldragon

    05/03/2023, 4:42 PM
    oh! nice
  • u

    Unsmart | Tech debt

    05/03/2023, 4:45 PM
    A completely different instance wont share limits. When the same instance handles many requests I'm not entirely sure how that works but I assume on a request coming in the limit gets set back to 1000 rather than each request getting its own limit of 1000 requests.
  • j

    john.spurlock

    05/03/2023, 6:41 PM
    so what is the practical limit these days on the amount of terminated ws connections one DO can hold indefinitely, assuming the DO is doing nothing but keeping them around in an array and republishing an incoming message outbound to all connections?
  • j

    john.spurlock

    05/03/2023, 6:42 PM
    i thought a limit of 500 would be safe, but seeing it plateau at around a hundred - and can't tell if this is due to usage, or the DO running out of resources
  • d

    Dani Foldi

    05/03/2023, 6:47 PM
    There is a hard limit of 1024 connections per instance somewhere in workerd - not documented anywhere though afaik - I've had success with 150, didn't test anything above
1...545546547...567Latest