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

    Yoni

    04/28/2021, 9:20 PM
    yup i had done something dumb in my code while trying random stuff to get the object to work. its all fixed now. thank you so much for the help
  • u

    Unsmart | Tech debt

    04/29/2021, 7:04 PM
    Btw just curious do websockets get charged per message sent or only based on how long its connected? Whenever I look at the metrics any websocket messages dont show up as requests so I assume its charged based on connection time?
  • e

    eidam | SuperSaaS

    04/30/2021, 6:47 AM
    I am still getting some
    Network connection lost.
    errors (sometimes ~400 errors a day) for requests interacting within DurableObjects. The stub is constructed every time, and its happening pretty random. Is there something known how to fix it or shall I just retry the DO request when it happens? Unfortunately I didn't have any luck replicating it.
  • b

    brett

    04/30/2021, 12:42 PM
    You should definitely add retry logic, since DO requests may cross the globe, some amount of connection loss is to be expected. That said, we're always working on improving that. Do you know what PoP you're hitting to access your normal worker?
    colo
    from here: https://www.cloudflare.com/cdn-cgi/trace And when you say ~400 in a day, out of how many requests total is that?
  • e

    eidam | SuperSaaS

    04/30/2021, 12:56 PM
    Sometimes it seems the DO is stuck, as repetitive requests fails as well. I will try to add some retry logic today, it should definitely narrow down potential bigger issue. 🙂 That’s a good point, it’s from ~500k daily requests
  • k

    kenton

    04/30/2021, 1:59 PM
    @User Do you recreate the client stub (calling
    namespace.get(id)
    ) for every request, or do you have one stub you're reusing across many requests?
  • e

    eidam | SuperSaaS

    04/30/2021, 2:01 PM
    recreating the stub for each request, using
    idFromName
  • k

    kenton

    04/30/2021, 2:02 PM
    ok... that's the right thing to do.
  • e

    eidam | SuperSaaS

    04/30/2021, 2:03 PM
    trying to improve the error logging a bit, so hopefully gonna give you more context soon
  • i

    infra

    04/30/2021, 5:37 PM
    The documentations on durable objects + websockets is still pretty spotty, I see this under DOs > Full documentation for WebSockets will be coming soon, but for now check out this heavily commented example chat application that runs in Durable Objects to see how it works. Unfortunately, I'm trying to do something that isn't reflected in the chat app - namely, have the DO act as a client to a websocket server abstracting over native code running on another machine, and route requests from workers to the backend via the DO websocket client connection.
  • i

    infra

    04/30/2021, 5:37 PM
    I could refactor my system to make the DO a WS server, perhaps, but everything's shaping up with the backend acting as the websocket server, exposed via a cloudflared tunnel.
  • i

    infra

    04/30/2021, 5:38 PM
    Is it possible for a DO to initiate a websocket client connection and proxy requests from workers to a third party websocket server? Seems like it should be, but I am at a bit of a loss with the DO + WS client mode combo.
  • v

    vans163

    04/30/2021, 6:24 PM
    Something I find very needed working with DOs/workers is support for https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror. A GlobalEventHandler for exceptions. So any crash anywhere, at any level, can be shipped off to our logging platform. (instead of having maticulous webs of try/catch/awaits, sending errors 1 way for websockets, sending errors another way for http requests.
  • v

    vans163

    04/30/2021, 6:55 PM
    How do you do a "Expect: 100-continue" inside a worker using fetch? I have an endpoint that wants to use this pattern
  • v

    vans163

    04/30/2021, 6:56 PM
    Basically the fetch gets the response headers, if the status code == 100, the fetch needs to start uploading the body. I dont see support inside fetch for this
  • d

    Deleted User

    04/30/2021, 7:22 PM
    ok wow i didnt know about that until now, thank you, i hate error handling
  • i

    infra

    04/30/2021, 8:26 PM
    DMs open, very interested to hear if this is tractable.
  • v

    vans163

    05/01/2021, 12:02 PM
    i think it should be possible, if you get it done and wanna share can you DM lol im curious too
  • b

    brett

    05/02/2021, 12:39 PM
    onerror
    does look nice, but I'm not sure why you need meticulous try/catches instead of it, why not a top level try/catch of your own? https://gist.github.com/bretthoerner/79cd3f823c9a7e2fa8adfb5a82d857d2
  • v

    vans163

    05/02/2021, 12:50 PM
    this does not work for backaround async awaits. (example calling a async function without awaiting for background task/sync)
  • v

    vans163

    05/02/2021, 12:50 PM
    so you get this messy stub for every function
  • b

    brett

    05/02/2021, 1:11 PM
    Yeah I guess you’d have to wrap each promise in a wrapper function, but that same wrapper could be used for all of those, at least
  • j

    jmshal

    05/03/2021, 5:13 AM
    Anybody know of any current issues/outages with DO? I'm just getting "internal error" when "fetching" on the DO stub.
  • w

    WhyNot

    05/03/2021, 7:11 AM
    same here. getting "internal error" when trying to fetch
  • j

    jmshal

    05/03/2021, 7:11 AM
    😢
  • j

    jmshal

    05/03/2021, 7:12 AM
    Real shame - because it's the last day of a hackathon I'm competing in, and we needed to record videos of our "creation"... and nothing's working :/
  • j

    jmshal

    05/03/2021, 8:19 AM
    Sadly we’ve had to throw in the towel with the hackathon. We unfortunately left it to the last day to record the video - our bad. I guess that’s how it goes with beta software 😅
  • m

    matt

    05/03/2021, 4:26 PM
    What's your nearest CF colo? https://cloudflare.com/cdn-cgi/trace will tell you
  • e

    eidam | SuperSaaS

    05/03/2021, 4:30 PM
    I also got 10.1k events in Sentry from around that time with "Internal Error", cant tell which colos were affected exactly
  • e

    eidam | SuperSaaS

    05/03/2021, 4:42 PM
    I can give you affected DO ids though, if there are no migrations in place yet it should tell you which colo was prob affected
1...757677...567Latest