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

    vans163

    05/13/2021, 7:57 PM
    this does not compile
  • b

    brett

    05/13/2021, 10:18 PM
    not always, the true location of
    idFromName
    objects is cached in each PoP
  • d

    Deebster

    05/14/2021, 5:37 AM
    is there a way to test for the existence of a DO by id? I'm generating via
    idFromName
    from a user-friendly char[5] code and I want to reroll this code if it's already in use. I suppose I could have my own DO that tracked these, but it seems like re-inventing the wheel.
  • j

    JuicyIce

    05/14/2021, 5:51 AM
    Guys, is there any ETA when you are coming out of Beta. 6 months, a year?
  • j

    JuicyIce

    05/14/2021, 5:54 AM
    You could set an isInitiated flag in your DO and when you get it by id check if it's true. I guess it should work. But there probably should be a better way
  • d

    Deebster

    05/14/2021, 5:57 AM
    yeah, I'd started to write that as another option but deleted it 😛 The point where I generate the code doesn't need to deal with the DO itself currently, but it could without too much pain.
  • v

    vans163

    05/14/2021, 3:41 PM
    followup on this. Is there a way to have
    fetch
    and
    scheduled
    handler in the same worker if ES6 is used?
  • e

    Erwin

    05/16/2021, 3:26 AM
    As a rule we don't announce roadmaps unfortunately. There are just way too many variables that can influence them. Especially something as new and cutting-edge as Durable Objects..
  • m

    Mooshua

    05/16/2021, 7:50 AM
    I have two primary questions at the moment: a) if DO relocation becomes a thing, how will it feel? Will it be automatic, or will DOs have a .moveToCurrentRegion() function? b) does DO data hope to be as reliable as Workers KV (as in practically 100%)?
  • s

    schickling

    05/16/2021, 2:36 PM
    Is there a way to list all object IDs/names? Something like
    OBJECT_NAMESPACE.list(): string[]
    ?
  • b

    brett

    05/16/2021, 4:02 PM
    not currently, a way to list is coming. for now you'd need to track object IDs in an external system like Workers KV (or another DO object)
  • b

    brett

    05/16/2021, 4:04 PM
    I can't speak to whether we'd ever allow manual relocation or not. We do offer jurisdictions but they aim to solve a specific problem: https://developers.cloudflare.com/workers/runtime-apis/durable-objects#:~:text=Durable%20Objects%20can%20be%20created,to%20comply%20with%20local%20regulations.&text=The%20jurisdiction%20constraint%20only%20controls,itself%20runs%20and%20persists%20data. and DO data is intended to be durable forever (it is replicated and backed up, of course). that said we don't necessarily make any promises during the beta period, AFAIK
  • v

    vans163

    05/16/2021, 11:17 PM
    Is there a way to unbound the execution time of a DO request? It seems when I do a setTimeout that calls another setTimeout, when some kindof CPU limit is reached, the setTimeout dies and fails to proc
  • v

    vans163

    05/16/2021, 11:17 PM
    I am trying to do a tick inside a DO
  • v

    vans163

    05/16/2021, 11:49 PM
    how can one have a cron callback and fetch in the same worker using ES6 (so DOs are callable?)
  • j

    jed

    05/17/2021, 1:29 AM
    i think it doesn't compile because you're missing a comma. object literals require them, class definitions don't.
  • v

    vans163

    05/17/2021, 1:30 AM
    But what object is this with a function inside? Never seen this documented on js. Il chrmeck tom ty
  • u

    Unsmart | Tech debt

    05/17/2021, 1:40 AM
    Yeah you need a comma, and thats just normal JS object syntax it always requires a comma to define a new variable/function
  • j

    jed

    05/17/2021, 1:45 AM
    that or
  • j

    jed

    05/17/2021, 1:46 AM
    see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions
  • m

    Murray

    05/17/2021, 10:44 AM
    Any chance the list DO API will support a start/end prefix like KV so it can be used as a secondary index to find DOs? As currently those tracking DO manually via KV have that option.
  • d

    Deebster

    05/17/2021, 1:09 PM
    I've got some websockets attached to a DO, using basically the chat demo. I connected from a phone and went into airplane mode to check the disconnect detection. There's no error being thrown by
    socket.send(message));
    and the DO seems to still consider it connected after about ten minutes now. Is the worker still alive and keeping the ws open? Is Cloudflare sending ping frames to test the connection?
  • d

    Deebster

    05/17/2021, 1:11 PM
    Oh, it just disconnected now. That's way too long...
  • d

    Deebster

    05/17/2021, 1:30 PM
    I just tried again, that was over 17 minutes and over 200 messages after the point that connection should have been dropped.
  • m

    matt

    05/17/2021, 3:06 PM
    Hey, sorry this took a while to answer. Modules currently aren't as well documented as we'd like, but in the meantime here's the proper syntax
    Copy code
    export default {
        async scheduled(controller, env, ctx) {
            // controller has scheduledTime and cron properties like ScheduledEvent
            // env has KV bindings, DO bindings, secrets, config vars, etc
            // ctx has waitUntil()
            
        }, // need commas between functions
        async fetch(req, env, ctx) { /*...*/ }
    }
  • d

    Deebster

    05/17/2021, 3:35 PM
    I've just run a few dozen tests, and 17/18 minutes is generally how long the zombie connections last. The number of messages they're meant to be receiving doesn't seem to matter.
  • v

    vans163

    05/17/2021, 4:24 PM
    You need to implement your own ping/pong. Tcpstack on phone I guess doesnt send rst packets on airplane mode turning on
  • d

    Deebster

    05/17/2021, 4:26 PM
    that's an option, of course, but the demo from Cloudflare is demoing functionality that doesn't work and I don't know if the CF guys know that
  • d

    Deebster

    05/17/2021, 4:28 PM
    https://github.com/cloudflare/workers-chat-demo/blob/b80a563527f549e99bef6548da64406a1326786a/src/chat.mjs#L412 <-- this never throws so the quitters code is never run
  • m

    Mooshua

    05/17/2021, 8:38 PM
    Good catch!
1...848586...567Latest