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

    PikaPika

    04/12/2021, 2:27 PM
    What is durable objects?
  • t

    theGagne

    04/12/2021, 2:59 PM
    @User your example itty-durable doesn't work for me, I get
    Copy code
    "message": "Uncaught ReferenceError: withDurables is not defined\n  at line 1\n  at line 1 in r\n  at line 1\n  at line 1\n"
  • t

    theGagne

    04/12/2021, 3:00 PM
    I think it just needs the import updated though?
  • k

    Kevin W - Itty

    04/12/2021, 3:18 PM
    oh geez, yeah add the
    import { withDurables } from 'itty-durable'
  • k

    Kevin W - Itty

    04/12/2021, 3:18 PM
    how embarrassing 😅
  • k

    Kevin W - Itty

    04/12/2021, 3:20 PM
    btw, I think I may change from extending a base class to a wrapper function to enable this functionality on the DO... stealing this from @User thanks to a convo this morning :p - means I can ditch the class factory function as well (the wrapper can just take options), and lets people keep their DO 100% pure for things like unit tests
  • k

    Kevin W - Itty

    04/12/2021, 3:21 PM
    i can proxy trap it all the same, allowing for all the same interface/lack-of-code
  • k

    Kevin W - Itty

    04/12/2021, 3:22 PM
    @User updated README https://www.npmjs.com/package/itty-durable
  • m

    mehdiiii

    04/12/2021, 3:25 PM
    I'm working on a library to make it easier to communicate with durable objects in the browser by making them feel like a local instance. Does anyone have a use case for this? I would love to hear about it. cc: @matt
  • m

    mehdiiii

    04/12/2021, 3:27 PM
    My goal is to land somewhere between Comlink and Firebase
  • k

    Kevin W - Itty

    04/12/2021, 3:31 PM
    I'm really hoping his library can just do everything mine does and better, so I can pass the torch entirely 😅
  • k

    Kevin W - Itty

    04/12/2021, 3:31 PM
    no pressure @User 🙂
  • m

    matt

    04/12/2021, 3:32 PM
    sounds interesting! I like the idea of extending the object stub to something you can use from the client and it feels like you're talking directly to a DO.
  • m

    matt

    04/12/2021, 3:33 PM
    as always, the challenge will be reducing network round trips
  • k

    Kevin W - Itty

    04/12/2021, 3:33 PM
    one challenge w that @User - now you'd want to include authentication within your DO to take browser requests directly, rather than piping them through a gateway Worker that handles auth
  • k

    Kevin W - Itty

    04/12/2021, 3:33 PM
    (at least where auth is required)
  • m

    matt

    04/12/2021, 3:34 PM
    you're always going to go through a normal worker to hit the DO, they can't service HTTP requests directly (i.e, have a route assigned to them)
  • t

    theGagne

    04/12/2021, 3:34 PM
    @User I get
    Copy code
    "message": "No event handlers were registered. This script does nothing.\n"
  • m

    mehdiiii

    04/12/2021, 3:34 PM
    Yeah I'd think all of that would be handled in your worker (re: auth)
  • n

    nightvisi0n

    04/12/2021, 3:52 PM
    Hi folks, while playing around with DO I'm currently stuck at
    fetch
    not being passed anything in it's
    env
    argument. I `JSON.stringify`'ed it for debugging purposes and it's indeed just an empty object. Any ideas what could be wrong?
  • n

    nightvisi0n

    04/12/2021, 3:54 PM
    I'm referring to the main exported
    fetch
    , like here: https://github.com/cloudflare/durable-objects-rollup-esm/blob/master/src/index.mjs#L8
  • m

    matt

    04/12/2021, 3:58 PM
    @User what are you expecting to be there? Do you have config vars/kv namespaces or similar set in your wrangler.toml?
  • n

    nightvisi0n

    04/12/2021, 4:00 PM
    I have a
    durable_objects
    binding in my
    wrangler.toml
    and would have expected to be able to access it via
    env
  • n

    nightvisi0n

    04/12/2021, 4:00 PM
    Like in this example: https://github.com/cloudflare/durable-objects-rollup-esm/blob/master/src/index.mjs#L18
  • m

    matt

    04/12/2021, 4:13 PM
    @User are you using wrangler environments
  • n

    nightvisi0n

    04/12/2021, 4:13 PM
    jup
  • m

    matt

    04/12/2021, 4:14 PM
    the
    [durable_objects]
    section is not inherited -- you'll need to provide it for each environment as a subtable of the environment, like
    [env.staging.durable_objects]
  • n

    nightvisi0n

    04/12/2021, 4:15 PM
    that's it, thanks!
  • t

    theGagne

    04/12/2021, 6:17 PM
    Was able to get my counter thing working with the help of @User , thanks so much!
  • t

    theGagne

    04/12/2021, 6:18 PM
    Does anyone know how to do crons with ES6 modules? I don't think this is working: export default { fetch: router.handle, --> working scheduled: cronHandler, --> not working }
1...565758...567Latest