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

    HardAtWork

    03/06/2023, 5:19 PM
    No, in your
    wrangler.toml
    .
  • h

    HardAtWork

    03/06/2023, 5:20 PM
    It might work with just the
    export class MyDOClass
    , but if it doesn't just add the
    export default {}
    .
  • m

    MisterNight

    03/06/2023, 5:20 PM
    do you have any suggestions for dev mode? should I be mocking out the worker interface? my code will be going through
    env.BINDING.etc
  • m

    MisterNight

    03/06/2023, 5:21 PM
    because I'd be using pages, I can't just use
    wrangler pages dev
    afaik
  • m

    MisterNight

    03/06/2023, 5:22 PM
    I could theoretically hit a different environment dev DO, but that seems wasteful on $ and requires connectivity while dev'ing
  • h

    HardAtWork

    03/06/2023, 5:22 PM
    wrangler
    should be able to connect to a DO automatically. If you run
    wrangler dev
    in your Worker, and then
    wrangler pages dev dist --do BINDING=MyDOClass
    , they should be able to link together...
  • m

    MisterNight

    03/06/2023, 5:23 PM
    I'll give this a shot
  • s

    Skye

    03/06/2023, 5:23 PM
    Yeah, afaik you should
    export class
    and
    export default
  • s

    Skye

    03/06/2023, 5:24 PM
    Though this will probably need to be
    --do BINDING=MyWorkerName@MyDoClass
  • m

    MisterNight

    03/06/2023, 5:24 PM
    next I'm wondering if I should manage all DOs as 1 wrangler package, or make each with their own wrangler.toml
  • u

    Unsmart | Tech debt

    03/06/2023, 5:25 PM
    dont think it matters that much but do note that when you deploy a worker all DOs will reset all active connections to do a code update and might throw some errors for a second or so
  • m

    MisterNight

    03/06/2023, 6:13 PM
    --do COUNTER=my_worker_name@Counter
    does not seem to be working unfortunately
  • m

    MisterNight

    03/06/2023, 6:13 PM
    I verified in cloudflare dash that it was published with
    my_worker_name
  • m

    MisterNight

    03/06/2023, 6:14 PM
    made the bindings in the pages project via dash
  • m

    MisterNight

    03/06/2023, 6:14 PM
    bound it as
    COUNTER
    and it has Durable object namespace of
    my_worker_name_Counter
  • m

    MisterNight

    03/06/2023, 6:15 PM
    [pages:err] DurableObjectError [ERR_CLASS_NOT_FOUND]: Class "Counter" for Durable Object "COUNTER" not found
  • s

    Skye

    03/06/2023, 6:15 PM
    Are you also running
    wrangler dev --local
    for your other worker name?
  • m

    MisterNight

    03/06/2023, 6:15 PM
    I was not
  • m

    MisterNight

    03/06/2023, 6:16 PM
    same problem though
  • m

    MisterNight

    03/06/2023, 6:16 PM
    yarn wrangler pages dev ./dist --compatibility-date=2023-03-04 --do COUNTER=my_worker_name@Counter --local
  • m

    MisterNight

    03/06/2023, 6:17 PM
    my DO's toml if that matters
    Copy code
    name = "my_worker_name"
    main = "./dist/index.mjs"
    compatibility_date = "2023-03-06"
    
    [build]
    command = "yarn install && yarn build"
    
    [durable_objects]
    bindings = [{name = "COUNTER", class_name = "Counter"}]
    
    [[migrations]]
    tag = "v1" # Should be unique for each entry
    new_classes = ["Counter"]
  • h

    HardAtWork

    03/06/2023, 6:18 PM
    Try —do COUNTER=Counter@my_worker_name
  • m

    MisterNight

    03/06/2023, 6:19 PM
    same
  • m

    MisterNight

    03/06/2023, 6:21 PM
    surely I don't need to redeploy the pages project @ CF right? since this is local
  • m

    MisterNight

    03/06/2023, 6:21 PM
    https://developers.cloudflare.com/pages/platform/functions/bindings/#durable-object-namespaces
  • s

    Skye

    03/06/2023, 6:21 PM
    For local dev, nothing matters about what's on production
  • s

    Skye

    03/06/2023, 6:21 PM
    Can you also share the command you're running the DO worker from?
  • m

    MisterNight

    03/06/2023, 6:22 PM
    yarn wrangler dev --local
    s
    t
    • 3
    • 22
  • j

    Jacob Wright

    03/07/2023, 7:41 PM
    Are DO auto-migrations (moving the data and DO closer to where it is being consistently accessed) still something Cloudflare is considering for the future? Is it still a ways out, or is it going to be worked on "soon"?
  • c

    ckoeninger

    03/07/2023, 8:30 PM
    not actively being worked on but in planning, if you have feedback on your use case / what you're expecting to gain / what you want to avoid I'd be curious to hear
1...509510511...567Latest