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

    Jacob | Pages

    02/18/2021, 11:06 PM
    Scary to think how much my 5GB MC world would cost on the edge 🤣
  • j

    Jacob | Pages

    02/18/2021, 11:10 PM
    I'm not looking to spend my life savings 😂
  • k

    kenton

    02/19/2021, 2:41 AM
    hey guys, let's try to keep the off-topic chat in #779390076219686943, thanks.
  • a

    andreev_io

    02/19/2021, 5:43 AM
    Hey everyone! I thought I had access to Durable Objects but I'm getting the
    workers.api.error.not_entitled
    error when trying to deploy with my account. Can I do anything about this? 😔
  • k

    kenton

    02/19/2021, 3:42 PM
    I'd suggest replying to the invite e-mail from Greg McKeon and tell him the problem.
  • r

    rita

    02/19/2021, 3:54 PM
    do you have a Workers bundled subscription? DO only works on the paid workers plan (that's what i've seen causing this error most often)
  • a

    andreev_io

    02/19/2021, 4:17 PM
    @User oooh i see. I didn't know that, thanks!
  • j

    jed

    02/20/2021, 1:23 PM
    i'm wondering how opaque a namespace's
    idFromName
    function is... given the result id, is it possible for someone to guess the input string? ie, can i, for example, use it as i would an HMAC function?
  • j

    jed

    02/20/2021, 2:06 PM
    potential use case is a stateless authorization model: (1) user hits
    /
    (2) i call
    crypto.getRandomValues
    to generate a token, store it in their cookie (3) i call
    idFromName
    with (2) to redirect the user to a url like
    /${id}
    (4) i call
    idFromString
    to fetch the DO based on the url id from (3) (5) user shares the url with other users, who connect (6) i know which user 'owns' the DO because
    idFromName(token)
    ===
    idFromString(id)
    .
  • o

    oleksandr

    02/20/2021, 9:23 PM
    note this is not stateless, the state has just moved to cookie
  • j

    jed

    02/20/2021, 9:50 PM
    sure, and workers aren’t serverless, the server is just run by cloudflare. the point is the state is outside of the system.
  • k

    kenton

    02/21/2021, 5:45 PM
    I would recommend using
    newUniqueId()
    rather than generate random bytes and pass it to
    idFromName()
    . Note that the IDs it produces are unguessable, with at least 128 bits of cryptographic entropy.
  • k

    kenton

    02/21/2021, 5:46 PM
    with that said,
    idFromName()
    derives the ID from a secure hash of the input, so it is not reversible.
  • j

    jed

    02/21/2021, 11:50 PM
    awesome, thanks @kenton. (i originally had
    newUniqueId
    as step one, but using it outside of stub fetching felt like an "abusage").
  • e

    eidam | SuperSaaS

    02/22/2021, 9:18 AM
    Is there a plan to have some kind of configurable ttl for durable objects (or its keys)? e.g. something that would clean up the storage if the specific DO wont get any requests/connections for 1 month
  • k

    kenton

    02/22/2021, 3:11 PM
    "Anyone with the link" sharing is an intended use case here. 🙂 That said, of course, you have to keep in mind that if someone hacks you (or... us) and gets a list of IDs then they can access all the objects. Whereas, with
    idFromName()
    , the name is not stored anywhere in our system. I'd like to add an option someday where you can opt out of being able to list the object IDs in return for a guarantee that there's no way for anyone to list them, and no way to access an object's contents without the ID (i.e. it becomes an encryption key for the specific object)... but we don't have that yet.
  • k

    kenton

    02/22/2021, 3:12 PM
    We're thinking of adding a general API to schedule a callback at a future time on a per-object basis, which you could then use to delete the object.
  • j

    jed

    02/22/2021, 3:13 PM
    a persistent
    setTimeout
    of sorts? that's a cool idea.
  • e

    eidam | SuperSaaS

    02/22/2021, 3:21 PM
    Nice, that could definitely be used for other purposes as well, like it!
  • k

    kenton

    02/22/2021, 3:22 PM
    yeah it's pretty clearly a necessary feature for a lot of things. Not just for scheduling, but the ability to retry after failures (including hardware failures).
  • w

    Wallslide

    02/22/2021, 10:30 PM
    Is there a handler I can export to save in-memory state to the persistent datastore right before being evicted from memory?
  • w

    Wallslide

    02/22/2021, 10:32 PM
    my thinking is that way I wouldn't have to await on storage and slow down responses to clients
  • n

    nilslice

    02/22/2021, 11:52 PM
    @User , does this help? https://developers.cloudflare.com/workers/learning/fetch-event-lifecycle#waituntil
  • n

    nilslice

    02/22/2021, 11:53 PM
    i'm not sure if that's available within the context of a durable object
  • w

    Wallslide

    02/23/2021, 12:28 AM
    if it is available, that would probably solve my usecase 🙂
  • w

    Wallslide

    02/23/2021, 12:28 AM
    thanks
  • n

    nilslice

    02/23/2021, 12:30 AM
    sure thing! let me know if it works out 🙂
  • j

    jed

    02/23/2021, 11:28 AM
    (it is available, as a method on the
    state
    object passed to the constructor. see: https://discord.com/channels/595317990191398933/802187271067140107/807309699544121384)
  • k

    kenton

    02/23/2021, 10:49 PM
    Poll: For those who have built something with Durable Objects, do you prefer to put your DO class(es) in a separate script from your non-DO fetch handler, or do you prefer to combine them in one script?
  • k

    kenton

    02/23/2021, 10:49 PM
    ^ @User
1...202122...567Latest