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

    jmshal

    04/10/2021, 8:28 PM
    Is there any reason I'd be getting "internal error" when trying to connect to a DO? I saw this the other day, but it was super late at night so I just called it a day and it was fixed by the morning, but I'm getting it again now.
  • j

    jmshal

    04/10/2021, 8:29 PM
  • k

    Kevin W - Itty

    04/10/2021, 8:29 PM
    Yeah, you should be able to call
    this.constructor.name
    from inside the DO unless i'm mistaken...
  • j

    jmshal

    04/10/2021, 8:30 PM
    Depending on whether your code is minified though, that may not work.
  • k

    Kevin W - Itty

    04/10/2021, 8:31 PM
    actually it's confirmed, I literally put that in my code a few min ago... haha
  • k

    Kevin W - Itty

    04/10/2021, 8:32 PM
    excellent point - mine currently isn't
  • d

    Deno

    04/10/2021, 8:35 PM
    message has been deleted
  • k

    Kevin W - Itty

    04/10/2021, 8:35 PM
    (overrides will be available)
  • d

    Deno

    04/10/2021, 8:40 PM
    message has been deleted
  • l

    luke

    04/10/2021, 8:53 PM
    What do you mean exactly by Q2?
  • k

    Kevin W - Itty

    04/10/2021, 8:58 PM
    with example DO:
  • k

    Kevin W - Itty

    04/10/2021, 8:58 PM
    with timestamps enabled, it would get initalize with
    { counter: 0, created: new Date }
  • k

    Kevin W - Itty

    04/10/2021, 8:59 PM
    and updates would add
    { modified: new Date }
  • k

    Kevin W - Itty

    04/10/2021, 9:00 PM
    with that, calls to
    increment()
    would bump the
    { modified }
    prop, and calls to
    add(a, b)
    would not (no change to log)
  • k

    Kevin W - Itty

    04/10/2021, 9:20 PM
    So regarding what will be published here in a few minutes... it'll be a DO base class (with factory for constructing base class with diff options), with middleware (for
    itty-router
    ) that allows for usage like this in your Worker:
  • k

    Kevin W - Itty

    04/10/2021, 9:21 PM
    Note, we've thrown out async setters (for now) entirely... gotta use methods to execute on the DO, or props/toJSON for reading
  • k

    Kevin W - Itty

    04/10/2021, 9:21 PM
    and see the actual DO code just above this in the thread
  • k

    Kevin W - Itty

    04/10/2021, 9:23 PM
    I'll try to record a screen cast explaining how it works - in the hopes that it inspires someone to come up with something even better 🙂
  • k

    Kevin W - Itty

    04/10/2021, 9:25 PM
    you'll have the option of accessing methods on the stub directly (as shown) or using the
    .fetch(request)
    on the stub manually and adding your own router flow to the durable (powerful for chained request behavior or more elaborate calls)
  • l

    luke

    04/10/2021, 11:12 PM
    awesome
  • l

    luke

    04/10/2021, 11:13 PM
    i like the option of magic timestamps, but not by default
  • l

    luke

    04/11/2021, 12:03 AM
    Is there a way to get Workers Sites workers to play nicely with DOs?
    [site]
    configuration in wrangler.toml doesn't seem to support
    upload_format="modules"
  • l

    luke

    04/11/2021, 12:06 AM
    also is there a reason Sites are configured separately from workers? the only difference seems to be a
    bucket
    option that uploads static assets to KV. I could imagine this being useful even for non-sites
  • l

    luke

    04/11/2021, 12:07 AM
    guess i should be asking in wrangler channel
  • k

    Kevin W - Itty

    04/11/2021, 12:18 AM
    you using the
    @cloudflare/wrangler@beta
    ?
  • k

    Kevin W - Itty

    04/11/2021, 12:19 AM
    although to be fair, I def haven't tried to integrate w Sites
  • k

    Kevin W - Itty

    04/11/2021, 12:22 AM
    Heads up all - I've released the super-early prototype of
    itty-durable
    https://www.npmjs.com/package/itty-durable This is a pretty tight coupling of itty-router and a durable base class (to extend) to remove nearly all DO boilerplate. Docs are sparse for now, and I apologize, but I'll rapidly move to flesh that out... any questions I'd recommend asking here (if not too lengthy as I already take up too much thread space here ;), on Twitter, or in GitHub issues on the repo itself. Really looking for early feedback on the usage, the interface, etc.
  • m

    mehdiiii

    04/11/2021, 1:24 AM
    I'm trying to do something similar to this rn
  • l

    luke

    04/11/2021, 5:12 AM
    using https://github.com/cloudflare/wrangler/releases/tag/v1.15.0-custom-builds-rc.2
  • g

    Greg Brimble | Cloudflare Pages

    04/11/2021, 10:48 AM
    @luke @Kevin W - Itty , Workers Sites doesn't work with the current release of wrangler beta. I wrote some PRs to add support (which have just been merged in), but they haven't been published as a new release yet. Check out #818615097731317802 for more info.
1...545556...567Latest