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

    john.spurlock

    08/03/2021, 1:48 PM
    I wonder if
    list
    and
    put(entries)
    also take similar optional bypass args...
  • v

    vans163

    08/03/2021, 1:48 PM
    ping on this issue, any way possible to get a reply?
    k
    • 2
    • 53
  • k

    kenton

    08/03/2021, 1:52 PM
    lol just came here to post that, you beat me
  • k

    kenton

    08/03/2021, 1:53 PM
    Yes, all the storage ops accept bypass flags. (For
    list()
    , they go into the existing options object. For others, it's a new parameter.)
  • k

    kenton

    08/03/2021, 2:00 PM
    (now that the post is out, I need to update the docs...)
  • k

    kenton

    08/03/2021, 2:05 PM
    Hey @User , do you see the same problem in a regular stateless worker (not a Durable Object)? Could you write a minimal self-contained worker that reproduces the problem which we could debug?
  • k

    kenton

    08/03/2021, 2:06 PM
    actually this should be a thread
  • w

    Wallacy

    08/03/2021, 3:22 PM
    Two questions: 1) It wasn't clear to me whether it's now better to "await" a .put() operation or rely on automatic await before the final response. 2) What's the behavior of ctx.waitUntil(()=> storage.put()) ?
  • h

    HardAtWork

    08/03/2021, 6:58 PM
    Hey @User, are there any plans for a DESTROY function or something similar, that would allow you to terminate a DO instance and wipe its data(
    OBJECT_NAMESPACE.get(id).destroy()
    )? Or a way to remotely force a reset of the DO from
    wrangler
    , without having to delete and recreate the instance?
  • k

    kenton

    08/03/2021, 7:06 PM
    If an object deletes all its storage (e.g. with
    storage.deleteAll()
    ), then it will cease to exist once it shuts down.
  • h

    HardAtWork

    08/03/2021, 7:07 PM
    How'd I miss that?
  • k

    kenton

    08/03/2021, 7:07 PM
    heh, it's definitely an unusual model and not obvious
  • k

    kenton

    08/03/2021, 7:08 PM
    but "implicit create, implicit delete" turns out to work really well because it means the clients don't have to check if an object exists or try to synchronize deletions... they just send messages to the object
  • h

    HardAtWork

    08/03/2021, 7:09 PM
    Is there a plan for the ability to wipe them from
    wrangler
    too? I sometimes make some changes to my code that might leave fragments in storage, so I want to start from scratch, without manually having to built that logic into the DO code.
  • a

    albert

    08/03/2021, 7:21 PM
    If I run
    deleteAll()
    on a
    idFromName()
    -object, can it migrate to a new PoP if created again?
  • h

    HardAtWork

    08/03/2021, 7:22 PM
    AFAIK, the
    deleteAll()
    function only works on
    this.state.storage
    inside the Durable Object, not in the Worker itself.
  • k

    kenton

    08/03/2021, 7:23 PM
    You can delete the whole namespace and recreate it from wrangler. We plan later to add the ability to list existing objects and perhaps to schedule a function to run on all objects.
  • a

    albert

    08/03/2021, 7:23 PM
    I actually meant running the function inside an object created using
    idFromName()
    - my fault.
  • h

    HardAtWork

    08/03/2021, 7:24 PM
    Yeah, it can recreate itself at another time, but without the previous storage.
  • a

    albert

    08/03/2021, 7:24 PM
    also at another PoP?
  • h

    HardAtWork

    08/03/2021, 7:24 PM
    Is that
    wrangler publish --delete-class MyClass
    , and
    wrangler publish --new-class MyClass
    ?
  • h

    HardAtWork

    08/03/2021, 7:25 PM
    Yeah, the recreation should then be by the nearest POP that is a valid DO hosting colo.
  • k

    kenton

    08/03/2021, 7:26 PM
    right
  • k

    kenton

    08/03/2021, 7:29 PM
    at present it's likely to stay at the same pop. To move to a new pop, you'd have to wait until all cached traces of the old object have been wiped from the system, which could take a while. But we're still working on automatic migration.
  • k

    kenton

    08/03/2021, 7:29 PM
    (though if you deleted the entire namespace and created a new one, then nothing carries over)
  • a

    albert

    08/03/2021, 7:32 PM
    Alright, that makes sense!
  • w

    Wallacy

    08/03/2021, 7:41 PM
    @User How the in/out gates plays with the ctx.waitUntil? Will this break the rules?
  • k

    kenton

    08/03/2021, 7:58 PM
    ctx.waitUntil()
    doesn't actually do anything in particular anymore. The object keeps running for at least 30 seconds after the last request whether or not use use waitUntil().
  • w

    Wallacy

    08/03/2021, 8:48 PM
    But if we use storage operations on the waitUntil, we will be able to make a response without actually wait.
  • k

    kenton

    08/03/2021, 11:06 PM
    Ah. Yes, deferring code to run after the response has already been returned is inherently unreliable, because in the case of a failure, no one finds out. E.g. if the power goes out, the task might never execute, but since the user already received a response, they won't know. Output gates can't help with this, since they can't predict what you're going to do in the future after you return the response. Generally, I don't recommend doing this, except maybe for stuff that is fine to be unreliable, like logging.
1...136137138...567Latest