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

    ttraenkler

    04/27/2021, 8:26 PM
    thanks, where do i find those release notes?
  • m

    matt

    04/27/2021, 8:27 PM
    We announce runtime releases in the community forums https://community.cloudflare.com/t/2021-4-15-workers-runtime-release-notes/261917
  • t

    ttraenkler

    04/27/2021, 8:29 PM
    thanks, is it possible to subscribe just to the release notes?
  • m

    matt

    04/27/2021, 8:30 PM
    https://community.cloudflare.com/tag/workersreleasenotes We tag the posts, so you could watch this page for changes, but afaik I don’t see a way to subscribe to them
  • t

    ttraenkler

    04/27/2021, 8:31 PM
    thanks, that already should help
  • u

    Unsmart | Tech debt

    04/27/2021, 8:55 PM
    Has anyone else noticed some really weird issues with websockets where if you try to disconnect it just doesnt disconnect? Testing with https://hoppscotch.io/realtime/ anytime I click disconnect nothing happens. But when using other WS servers it disconnects fine.
  • u

    Unsmart | Tech debt

    04/27/2021, 8:57 PM
    Ah interesting... if a client doesnt send a message to the server and you click disconnect it gets stuck in the closing state for a while I always refreshed to fast. If I send a message then click disconnect its instant.
  • m

    Mallissin

    04/28/2021, 1:08 AM
    Is this because the DO isn't "hot"? You only have 500ms.
  • v

    vans163

    04/28/2021, 1:21 AM
    anyone have statsd metrics for datadog that work inside a DO/worker?
  • v

    vans163

    04/28/2021, 3:14 AM
    is there a way to get lat and long inside a DO?
  • v

    vans163

    04/28/2021, 3:14 AM
    or does it currently need to be passed in from the worker?
  • p

    preethi

    04/28/2021, 3:36 AM
    So in-memory storage means some space allocated for DO not worker. All state would be only in DO. Those data in DO should not be moved to worker and perform any computation?
  • u

    Unsmart | Tech debt

    04/28/2021, 5:30 AM
    That actually was just normal worker websockets havent gotten to get it to work on DO yet because itty-durable has a bug with it so not entirely sure but possibly something like that.
  • j

    john.spurlock

    04/28/2021, 2:15 PM
    Currently, the
    cf
    object is unavailable in module workers, but it sounds like the info will be available at some point in some form in the future. For DO fetches though, you'll probably always want to pass it in from the original client request https://discord.com/channels/595317990191398933/773219443911819284/834489479833059370
  • v

    vans163

    04/28/2021, 2:33 PM
    k il wait thanks
  • y

    Yoni

    04/28/2021, 7:07 PM
    Having issues with my durable objects:
    Copy code
    toml
    # wrangler.toml
    [durable_objects]
    
    bindings = [{name = "ROLE_MANAGER", class_name = "RoleManager"}]
    Copy code
    typescript
    // role-manager-durable-object.ts
    export class RoleManager implements DurableObject {
    ...
    // index.ts
    import { RoleManager } from './role-manager-durable-object'
    
    export default {
      async fetch(request: Request, env: Env) {
        try {
          env.ROLE_MANAGER.idFromName('someId')
        } catch (e) {
          return new Response(e.message)
        }
        return new Response('')
      }
    }
    
    export { RoleManager }
    and ive run
    wrangler publish --env production --new-class RoleManager
    and this code returns
    Cannot read property 'idFromName' of undefined
  • m

    matt

    04/28/2021, 9:10 PM
    @User does the
    Env
    type include the
    ROLE_MANAGER
    property? If so, its very likely the problem here is with your typescript setup -- whats your typescript config and build process look like?
  • y

    Yoni

    04/28/2021, 9:11 PM
    Its just an interface
    Copy code
    ts
    export interface Env {
      DISCORD_APP_ID: string
      DISCORD_PUBLIC_KEY: string
      DISCORD_TOKEN: string
      ROLE_MANAGER: DurableObjectNamespace
    }
    it shouldnt affect the code right? in the outputted
    index.mjs
    , i see
    ...async fetch(e,n){try{n.ROLE_MANAGER...
  • y

    Yoni

    04/28/2021, 9:12 PM
    ill paste my ts and rollup configs
  • y

    Yoni

    04/28/2021, 9:12 PM
    Copy code
    json
    {
      "compilerOptions": {
        "outDir": "./tsc-dist",
        "module": "ESNext",
        "target": "ES2019",
        "lib": ["esnext", "webworker"],
        "alwaysStrict": true,
        "strict": true,
        "preserveConstEnums": true,
        "moduleResolution": "node",
        "sourceMap": true,
        "esModuleInterop": true,
        "types": ["@cloudflare/workers-types"]
      },
      "include": [
        "./src/*.ts",
        "./src/**/*.ts",
        "./node_modules/@cloudflare/workers-types/index.d.ts"
      ],
      "exclude": [
        "node_modules/",
        "./test/*.ts",
        "./test/**/*.ts",
        "dist/",
        "tsc-dist/"
      ]
    }
  • y

    Yoni

    04/28/2021, 9:12 PM
    Copy code
    js
    import { terser } from 'rollup-plugin-terser'
    import { nodeResolve } from '@rollup/plugin-node-resolve'
    import commonjs from '@rollup/plugin-commonjs'
    
    export default {
      input: 'tsc-dist/index.js',
      output: {
        exports: 'named',
        format: 'es',
        file: 'dist/index.mjs',
        sourcemap: false,
      },
      plugins: [commonjs(), nodeResolve({ browser: true }), terser()],
    }
  • m

    matt

    04/28/2021, 9:12 PM
    are you using wrangler environments?
  • m

    matt

    04/28/2021, 9:13 PM
    the
    [durable_objects]
    section isn't inherited
  • y

    Yoni

    04/28/2021, 9:13 PM
    ooo so i need to do
    Copy code
    toml
    [env.production.durable_objects]
    bindings = [{name = "ROLE_MANAGER", class_name = "RoleManager"}]
    ?
  • m

    matt

    04/28/2021, 9:13 PM
    yup!
  • y

    Yoni

    04/28/2021, 9:13 PM
    let me try that rn
  • m

    matt

    04/28/2021, 9:13 PM
    the migrations will need to be done for each environment as well, as each environment is its own script
  • m

    matt

    04/28/2021, 9:14 PM
    ts/rollup config looks good
  • y

    Yoni

    04/28/2021, 9:14 PM
    that worked! now i get
    Some functionality, such as asynchronous I/O, timeouts, and generating random values, can only be performed while handling a request.
    i probably just did something wrong
  • m

    matt

    04/28/2021, 9:15 PM
    that's thrown when you try to do something in global scope or a durable object constructor that falls under that category
1...747576...567Latest