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

    molmorg

    04/22/2021, 2:08 AM
    I think I saw some types for DurableObjects somewhere (for TypeScript). Can no longer find them... did I dream?
  • m

    molmorg

    04/22/2021, 2:31 AM
    Also, trying to export my TypeScript DurableObject "LogTopic" from index.ts. Using this syntax right now
    export type { LogTopic}  from "./LogTopic"
    But no joy...
    "Cannot create binding for class LogTopic that is not exported by the script"
  • j

    jmshal

    04/22/2021, 6:10 AM
    That's because part of your deployment script to CF Workers will be minifying the code. And part of that minification step will be renaming variable names, and in your case: class names.
  • d

    doublebeat

    04/22/2021, 6:55 AM
    Does anyone know why in
    1.16
    I can't call
    --new-class
    in
    wrangler publish
    ?
  • v

    vans163

    04/22/2021, 8:43 AM
    Is there a correct way to get the name of the DO then from inside the DO?
  • t

    ttraenkler

    04/22/2021, 9:11 AM
    is it possible to use DOs with typescript at the moment?
  • u

    Unsmart | Tech debt

    04/22/2021, 9:33 AM
    Im assuming by that you just mean are there typings. In which case yes there is from
    @cloudflare/workers-types
  • t

    ttraenkler

    04/22/2021, 10:16 AM
    more like in how to set it up. we're using the default webpack at the moment. from searching this channel i assume we have to migrate to rollup to get it to work?
  • d

    dbingel

    04/22/2021, 11:04 AM
    You can find them in https://github.com/cloudflare/workers-types (e.g. https://github.com/cloudflare/workers-types/blob/master/index.d.ts#L676) There is no type for WebSocketPair yet. An issue has already been opened under https://github.com/cloudflare/workers-types/issues/84.
  • v

    vans163

    04/22/2021, 1:05 PM
    This is actually a bug in my code related to the magical realm of OOP and
    this
    pointers. the
    this
    pointer inside a lambda/anonfunc seems to be thrown off.
  • v

    vans163

    04/22/2021, 1:20 PM
    it seems the only way I can make the DO be aware of the name it has is by passing in the name with the worker fetch in the path?
  • v

    vans163

    04/22/2021, 1:20 PM
    seems kinda broken
  • v

    vans163

    04/22/2021, 1:21 PM
    i can get the internal ID no problem tho but its a hex string
  • k

    kenton

    04/22/2021, 5:56 PM
    Yeah this looks like a bug in our implementation. The standard says the arguments are optional, but apparently I didn't implement it that way.
  • k

    kenton

    04/22/2021, 5:57 PM
    I will try to get that fixed
  • k

    kenton

    04/22/2021, 5:59 PM
    Yes, you need to track the name separately. The system doesn't actually track the name. When you run
    idFromName(name)
    , you get an ID back, and the system doesn't remember the original name anywhere... it's basically a hash.
  • k

    kenton

    04/22/2021, 6:20 PM
    I've implemented a fix to make close() arguments optional. It should roll out next week.
  • m

    molmorg

    04/22/2021, 6:22 PM
    still struggling with this... I took a look at my rollup output - a .mjs file that ends as follows:
    Copy code
    export default g;
    export { h as LogTopic };
    Where
    h
    is the Durable Object class. But still getting that error:
    "Cannot create binding for class LogTopic that is not exported by the script"
    any ideas?
  • m

    matt

    04/22/2021, 6:45 PM
    @User the rollup output is declared as the main module in
    wrangler.toml
    right? that syntax looks correct
  • m

    matt

    04/22/2021, 6:45 PM
    you need to be using 1.16.0-durable-objects-rc.0, install instructions are on the wrangler github releases page
  • v

    vans163

    04/22/2021, 6:50 PM
    got it, if the DO is spun up, is the cost of resolving the name close to the same as using the ID? because I have DOs calling DOs, and i just got to thinking once I am inside the DO i can pass the id of the DO to the callee so the callee can call it back at a later time
  • v

    vans163

    04/22/2021, 6:50 PM
    right now i am passing the unique name (that is their userid basically)
  • m

    molmorg

    04/22/2021, 6:52 PM
    yep - the module was also publishing fine until I added DurableObjects.
  • m

    matt

    04/22/2021, 6:52 PM
    @User got a repo link?
  • m

    molmorg

    04/22/2021, 6:53 PM
    let me upload now
  • m

    molmorg

    04/22/2021, 6:54 PM
    https://github.com/joshtwist/cf-logger
  • m

    matt

    04/22/2021, 6:59 PM
    only bug I could find is
    main
    should be just
    ./index.mjs
  • m

    matt

    04/22/2021, 6:59 PM
    the path is relative from
    upload.dir
    (which defaults to dist)
  • m

    matt

    04/22/2021, 7:00 PM
    I can't replicate the error message you're getting, if you change that does it fix it?
  • m

    matt

    04/22/2021, 7:01 PM
    @User ^ (forgot to tag)
1...686970...567Latest