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

    avi

    03/30/2023, 9:49 PM
    so i'm worried i'll have tons of "zombie" DO instances that should be recycled so i can reuse their IDs
  • a

    avi

    03/30/2023, 9:50 PM
    (more accurately, reuse the human-readable short name that i use via
    idFromName
    )
  • c

    ckoeninger

    03/30/2023, 9:51 PM
    if you're not using persistent storage at all, the only thing that will remain after the DO leaves memory is its location, and that's an issue we know we'll need to address
  • a

    avi

    03/30/2023, 9:51 PM
    its location? like its ID?
  • c

    ckoeninger

    03/30/2023, 9:51 PM
    to put it another way, if you clear any relevant inmemory state after the last disconnect, what stops you from reusing it?
  • c

    ckoeninger

    03/30/2023, 9:51 PM
    no its geographic location
  • a

    avi

    03/30/2023, 9:52 PM
    oh interesting — when i call that API, i get a bunch of stuff like:
  • a

    avi

    03/30/2023, 9:52 PM
    Copy code
    {
          "hasStoredData": false,
          "id": "bdda1d6abcd38026abd764310cadebcc54027dfca8ea795de615b9574d94a6bd"
        },
        {
          "hasStoredData": false,
          "id": "ac1fac7483039d661f5b5d65fc3f0251b82c21a9628bc3e4c1476411bc6fe2f1"
        },
  • a

    avi

    03/30/2023, 9:52 PM
    i want those iDs to go away
  • c

    ckoeninger

    03/30/2023, 9:52 PM
    yeah
    hasStoredData: false
    there means there's nothing stored
  • c

    ckoeninger

    03/30/2023, 9:52 PM
    how could you tell if they went away, aside from the geographic location? there's no other state
  • a

    avi

    03/30/2023, 9:53 PM
    this API i suppose 😉
  • a

    avi

    03/30/2023, 9:53 PM
    i guess you're saying: 'don't worry about it"
  • a

    avi

    03/30/2023, 9:53 PM
    i'm not charged for those things right?
  • a

    avi

    03/30/2023, 9:53 PM
    since there's no storage and assuming nobody is connected
  • c

    ckoeninger

    03/30/2023, 9:53 PM
    as long as they aren't running and don't have any persistent storage
  • c

    ckoeninger

    03/30/2023, 9:53 PM
    correct
  • a

    avi

    03/30/2023, 9:53 PM
    i'd love to, is there some hook i can use for this?
  • c

    ckoeninger

    03/30/2023, 9:55 PM
    not really, it'd just be a question of clearing any instance variables you were using
  • c

    ckoeninger

    03/30/2023, 9:55 PM
    don't use global variables 😉
  • a

    avi

    03/30/2023, 9:55 PM
    another question is, it's say i do make use of the DO Storage API. i'd want some way to bulk-delete all those DOs, for example if i deploy a new version of the gameserver worker and i actively do not want the old state because it could have unintended consequences
  • a

    avi

    03/30/2023, 9:56 PM
    oh yeah, i mean a hook to know when the last player disconects. clearing the in-memory state is easy. knowing reliably when to do it is the hard part
  • c

    ckoeninger

    03/30/2023, 9:57 PM
    either delete the namespace, or walk every object from the list object api and call state.storage.deleteAll
  • c

    ckoeninger

    03/30/2023, 9:58 PM
    I'm assuming you're tracking all open websockets anyway, right?
  • a

    avi

    03/30/2023, 9:58 PM
    true
  • a

    avi

    03/30/2023, 9:58 PM
    i guess just in the ondisconnect/onerror handler
  • a

    avi

    03/30/2023, 9:59 PM
    i guess the only situation that wouldn't reliably be called after the last player disconnects is if the DO crashes or is killed
  • a

    avi

    03/30/2023, 9:59 PM
    but in that case, state is necessarily cleared anyway
  • a

    avi

    03/30/2023, 10:00 PM
    got it. is there any concept of 'versioning' for DOs? i guess just environments?
  • c

    ckoeninger

    03/30/2023, 10:03 PM
    no versioning
1...531532533...567Latest