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

    avi

    03/25/2023, 10:50 PM
    or even just browse what exists?
  • w

    wot

    03/25/2023, 10:57 PM
    Are durable object automatic retries for alerts billed as additional request?
  • a

    avi

    03/26/2023, 1:10 AM
    mind re-uploading this? would love to see how you managed to figure this out. i'm struggling to create what should be an incredibly simple proof of concept: Pages + a single durable object.
  • a

    avi

    03/26/2023, 1:11 AM
    this is my dev command:
    wrangler pages dev --local --do=COUNTER=Counter -- vite dev
  • h

    HardAtWork

    03/26/2023, 7:24 AM
    You need a second Worker, also running dev
    a
    f
    z
    • 4
    • 23
  • c

    ckoeninger

    03/27/2023, 2:37 PM
    https://developers.cloudflare.com/api/operations/durable-objects-namespace-list-objects
  • a

    avi

    03/27/2023, 10:03 PM
    thanks - this tells me which DOs have data attached, but I want to actually download/export that data. any way to do that?
  • c

    ckoeninger

    03/27/2023, 10:20 PM
    for each of those DOs, request the data that you want
  • c

    ckoeninger

    03/27/2023, 10:21 PM
    there's no built in bulk export
  • f

    four33

    03/27/2023, 11:39 PM
    is it possible to add a service binding for a durable object without writing a toml file? I'm adding
    --do THING=Thing
    to
    wrangler pages dev
    but all I get is a
    DurableObjectError [ERR_CLASS_NOT_FOUND]
    . I'm basically trying to add a binding for durable objects to a Pages/Functions project
  • f

    four33

    03/27/2023, 11:43 PM
    From `wrangler pages dev --help`:
    --do Durable Object to bind (--do NAME=CLASS) [array]
    Where does this class export live? I've tried putting it in the pages function, in the functions directory, in the src/ directory and at the root
  • m

    mhazy

    03/28/2023, 12:51 AM
    Attempting to add DO bindings and not seeing the option on our account (paid tier) -- are the instructions wrong or something off with our accounts? This is for Pages, at the moment.
  • w

    Walshy | Pages

    03/28/2023, 12:53 AM
    It looks like you have no published DOs
  • w

    Walshy | Pages

    03/28/2023, 12:53 AM
    Have you created any?
  • m

    mhazy

    03/28/2023, 12:56 AM
    Definitely not, that wasn't clear from the Pages docs -- thanks for the heads up, I'll dig into the Workers docs.
  • u

    Unsmart | Tech debt

    03/28/2023, 1:09 AM
    The message on the dashboard says you have no durable objects created not really sure how they could make that more clear but I'm sure suggestions could be helpful
  • h

    HardAtWork

    03/28/2023, 6:14 AM
    You have to run a separate
    wrangler dev
    session which declares the DO
  • j

    jan

    03/28/2023, 9:21 AM
    I'm also trying to achieve the same as four33. I have two repos: a pages project, and a worker that exports a
    Player
    DO class. I'm running
    wrangler dev
    inside the worker repo, but running
    wrangler pages dev --do players=Player
    in my pages project yields
    DurableObjectError [ERR_CLASS_NOT_FOUND]: Class "Player" for Durable Object "player" not found
    . I'm assuming I'm either doing something wrong when running the pages command, or maybe the worker's
    wrangler.toml
    is missing something? The worker itself works fine when I publish it, and the DO appears as possible bindings in the pages dashboard. Is there anything else I should do to "declare the DO" locally? Appreciate any pointers you might have 😊
  • h

    HardAtWork

    03/28/2023, 9:23 AM
    I believe the command for Pages would be
    Copy code
    sh
    wrangler pages dev --do players=Player@WorkerScriptName
    , and replace
    WorkerScriptName
    with the name of the script that exposes your
    Player
    DO class.
  • j

    jan

    03/28/2023, 9:27 AM
    Wow, that did the trick! Thanks a bunch!
  • f

    four33

    03/28/2023, 1:01 PM
    Thanks for the help!
  • f

    four33

    03/28/2023, 1:02 PM
    @Unsmart | Tech debt I think the dashboard is clear, but I think there's obviously a bit of confusion about using durable objects with Pages. It's not immediately apparent that you have to create a separate wrangler config/run another wrangler session to populate the DO. I guess I would have expected a class export from a function to get picked up by
    wrangler pages dev
    with the
    --do
    flag.
  • f

    four33

    03/28/2023, 3:04 PM
    What's the trick to getting these bindings working locally with pages dev? I have a durable object + a worker published, I'm pointing to it with the
    --do
    flag, but my
    context.env
    doesn't contain that Durable Object namespace
  • f

    four33

    03/28/2023, 3:20 PM
    wrangler dev --local
  • h

    HardAtWork

    03/28/2023, 3:21 PM
    How are you testing whether it exists?
  • f

    four33

    03/28/2023, 3:23 PM
    I was just logging context.env
  • f

    four33

    03/28/2023, 3:23 PM
    but resolved now, running
    wrangler dev --local
    from my worker
  • h

    HardAtWork

    03/28/2023, 3:32 PM
    It shouldn’t resolve. IIIRC, the env object isn’t serializable, so it should just log as
    {}
  • f

    four33

    03/28/2023, 3:43 PM
    nah it does
  • f

    four33

    03/28/2023, 3:44 PM
    Copy code
    console.log(context.env)
    
    {
      KV_NAMESPACE: KVNamespace,
      SOME_ENV_VAR: 'abc123',
      DO_NAMESPACE: DurableObjectNamespace
    }
    etc
1...525526527...567Latest