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

    Erwin

    08/16/2021, 6:16 AM
    I don't know for sure, but if they are the same for multiple requests over a single connection over HTTP2, then I think that might be the case indeed.
  • m

    mikeysee

    08/16/2021, 12:20 PM
    Anyone know why I am getting this error when trying to access a durable object?
    ID is not for this Durable Object class.
  • m

    mikeysee

    08/16/2021, 12:20 PM
    Copy code
    ts
    const stub = env.UsersProjection.get(env.EventStore.idFromName(`a`));
    
      console.log(`querying projection`, {
        projection,
        query,
      });
    
      const response = await stub
        .fetch(`query`, {
          method: "POST",
          body: JSON.stringify(query),
        })
        .then(r => r.json());
    
      console.log(`projection query response`, response);
  • m

    mikeysee

    08/16/2021, 12:20 PM
    scratch thatr
  • m

    mikeysee

    08/16/2021, 12:20 PM
    I see the problem 😛
  • m

    mikeysee

    08/16/2021, 12:21 PM
    https://tenor.com/view/large-duck-cute-giant-duck-huge-duck-gif-17586378
  • m

    mikeysee

    08/16/2021, 12:32 PM
    is there a way to compress a DurableObject ID to something that is smaller but still URL friendly? "8adb1bfbbb192fd4642d90daf3f6f9945b2c7bf7f375dde8e5f2dcc8fbd63c0b" is pretty long but its hex so it should be possible to convert it to a url-friendly alphabet yes?
  • a

    albert

    08/16/2021, 12:47 PM
    @mikeysee You could use base64 and swap
    / and +
    with
    - and _
    to make it URL-friendly.
  • a

    albert

    08/16/2021, 12:50 PM
    or you could use
    idFromName()
    and just use the name in the URL
  • m

    mikeysee

    08/16/2021, 12:56 PM
    cheers, ye but I still want it to be globally unique tho
  • a

    albert

    08/16/2021, 12:57 PM
    Then use this method 🙂 @mikeysee
  • m

    mikeysee

    08/16/2021, 12:57 PM
    sorry to be dumb but how would one go about converting "8adb1bfbbb192fd4642d90daf3f6f9945b2c7bf7f375dde8e5f2dcc8fbd63c0b" to base64?
  • m

    mikeysee

    08/16/2021, 12:57 PM
    ah I see: https://base64.guru/converter/encode/hex
  • m

    mikeysee

    08/16/2021, 12:58 PM
    "itsb+7sZL9RkLZDa8/b5lFsse/fzdd3o5fLcyPvWPAs=" not really all that much shorter
  • m

    mikeysee

    08/16/2021, 12:59 PM
    what I really want is https://github.com/oculus42/short-uuid but unfortunately it relies on nodes "crypto" package
  • m

    mikeysee

    08/16/2021, 12:59 PM
    not sure how to get around that
  • a

    albert

    08/16/2021, 1:00 PM
    https://stackoverflow.com/a/54095276
  • m

    mikeysee

    08/16/2021, 1:00 PM
    sud
  • a

    albert

    08/16/2021, 1:00 PM
    You need to convert to bytes first
  • a

    albert

    08/16/2021, 1:01 PM
    Oh, it does that already. Never mind.
  • a

    albert

    08/16/2021, 1:01 PM
    But yeah, it'll only be like 25% shorter.
  • w

    Wallacy

    08/16/2021, 4:07 PM
    On my system i use base36 everywhere. Then i dont need to handle issues related to upper/lowercase and no "/" or "+" ... Is just a simple toString(36);
  • w

    Wallacy

    08/16/2021, 4:11 PM
    Saying that, the size problem is related of the size of the original id/info. The object id (8adb1bfbbb192fd4642d90daf3f6f9945b2c7bf7f375dde8e5f2dcc8fbd63c0b) is 256 bits wide. Any lossless encoder to reduce this size still be limited to this reality. The "short-uuid" project uses base58, so will be larger than using base64. You can try Base-96 ...
  • w

    Wallacy

    08/16/2021, 4:12 PM
    But at end of the day, doesn't matter the size, will always be ugly.
  • b

    brett

    08/16/2021, 4:13 PM
    You can always give them your own name and store a lookup in another DO, or KV, etc
  • b

    brett

    08/16/2021, 4:13 PM
    (Or use a named object, but it sounds like you want unique IDs)
  • w

    Wallacy

    08/16/2021, 4:15 PM
    And thats what i do, i really don't store Durable Ids. I already have my unique IDs (base36 128bits/26char long) ... So i use that using idFromName()
  • g

    gzalo

    08/16/2021, 10:18 PM
    Do we know if there's any way to detect a DO data loss event, or should we assume that the storage API will return undefined, as if the keys had been deleted?
  • e

    Erwin

    08/16/2021, 11:02 PM
    What do you mean with a data loss event?
  • e

    Erwin

    08/16/2021, 11:02 PM
    When a DO can't succesfully write to storage?
1...156157158...567Latest