https://discord.cloudflare.com logo
Join Discord
Powered by
# workers-discussions
  • c

    Crazy Rabbit

    03/23/2023, 2:52 PM
    thanks
  • d

    DanTheGoodman

    03/23/2023, 3:16 PM
    For workers (not DOs) with a websocket connection are they billed by the time the websocket is connected, or only the time processing messages?
  • s

    Skye

    03/23/2023, 3:17 PM
    From my understanding, the worker still has to be kept alive while a client is connected, so you'll be billed for the whole duration
  • h

    HardAtWork

    03/23/2023, 3:17 PM
    Right now the whole time, but soon there will be an API to hibernate it
  • k

    kian

    03/23/2023, 3:17 PM
    That'd only be for DOs though, right?
  • h

    HardAtWork

    03/23/2023, 3:19 PM
    Probably, yes
  • h

    HardAtWork

    03/23/2023, 3:19 PM
    Gotta check the docs
  • d

    DanTheGoodman

    03/23/2023, 3:19 PM
    for the example of asynclocalstorage, that wouldn't work within a DO because the thread is shared, correct? Only works in the case of workers because the are dedicated thread per request?
  • d

    DanTheGoodman

    03/23/2023, 3:20 PM
    Yeah I'd love to be able to just have websockets open that invoke a worker when a message goes through so that I can do a socket proxy to an api
  • d

    DanTheGoodman

    03/23/2023, 3:20 PM
    without needing th eworker for the whole websocket, just the message
  • h

    HardAtWork

    03/23/2023, 3:20 PM
    Regular Workers aren’t single thread per request, I don’t think
  • d

    DanTheGoodman

    03/23/2023, 3:20 PM
    well I meant like they script context is not shared
  • d

    DanTheGoodman

    03/23/2023, 3:21 PM
    IIUC
  • h

    HardAtWork

    03/23/2023, 3:21 PM
    Globals are, iirc
  • h

    HardAtWork

    03/23/2023, 3:21 PM
    Which is why SW syntax is so slow
  • d

    DanTheGoodman

    03/23/2023, 3:21 PM
    sw?
  • k

    kian

    03/23/2023, 3:21 PM
    Service Workers -
    addEventListener
  • d

    DanTheGoodman

    03/23/2023, 3:22 PM
    gotcha
  • d

    DanTheGoodman

    03/23/2023, 3:22 PM
    yeah I don't use that lol
  • h

    HardAtWork

    03/23/2023, 3:24 PM
    But yeah, the whole reason they added piped in env vars was so that they could modify them on request, rather than having to reboot the entire isolate first
  • d

    DanTheGoodman

    03/23/2023, 3:24 PM
    makes sense, was just wishful hoping XD
  • k

    kian

    03/23/2023, 3:28 PM
    It sounds like you want WebSocket hibernation with Durable Objects, based off this
  • k

    kian

    03/23/2023, 3:28 PM
    but of course that's only a DO thing
  • s

    Spoleto

    03/23/2023, 3:50 PM
    Can we revisit this? Any way to detect IF crawler using cloudflare worker on PRO plan?
    k
    d
    • 3
    • 34
  • d

    DanTheGoodman

    03/23/2023, 4:13 PM
    No I want it stateless, just a proxy for an api
  • d

    dave

    03/23/2023, 5:58 PM
    How do you folks use Jest in your Workers?
  • d

    dave

    03/23/2023, 5:59 PM
    I kinda want to expose a health check endpoint that uses Jest to test all the other endpoints.
  • g

    GeorgeTailor

    03/23/2023, 7:18 PM
    hello, how to avoid
    Unhandled Promise Rejection: Error: recursive use of an object detected which would lead to unsafe aliasing in rust
    when using HTMLRewriter to append elements? This is the code that fails:
    Copy code
    class SimilarWordsElementHandler {
        constructor(similarWords) {
            this.similarWords = similarWords;
        }
        async element(element) {
            element.setInnerContent(null);
            for (const similarWord of this.similarWords) {
                element.append(`<li>
                    <a href='/word/${encodeURIComponent(similarWord)}'>
                        <span>${similarWord}</span>
                    </a>
                </li>`, { html: true });
            }
        }
    }
  • d

    DemosJarco

    03/23/2023, 11:01 PM
    What's the difference between the
    nodejs_compat
    flag from today's post (https://blog.cloudflare.com/workers-node-js-asynclocalstorage/) and the
    node_compat = true
    flag that has been available all this time?
  • k

    kian

    03/23/2023, 11:02 PM
    node_compat = true
    is just polyfills in esbuild
1...235623572358...2509Latest