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

    Murder Chicken

    04/23/2023, 1:50 PM
    Copy code
    export async function doRequests(requests) {
      const responses = await Promise.all(requests.map(request => fetch(request)))
      const responseData = await Promise.all(responses.map(response => response.json()))
      return responseData
    }
  • k

    kian

    04/23/2023, 1:51 PM
    I would assume that you're not reaching
    responseData
    until all of the
    responses
    have been resolved?
  • m

    Murder Chicken

    04/23/2023, 1:56 PM
    Likely? I'm trying to determine how to have the requests processed as soon as they're complete. First attempt at this and I see numerous examples out there. Coming from a non-event loop language, this is a bit of a learning curve.
  • s

    Skye

    04/23/2023, 1:58 PM
    You could maybe do
    Copy code
    js
    const responseData = await Promise.all(requests.map(request => fetch(request).then(r => r.json()))
  • s

    Skye

    04/23/2023, 1:59 PM
    so it'll read each body as soon as the request completes, opening up the next one to go ahead
  • m

    Murder Chicken

    04/23/2023, 2:00 PM
    Thanks for the input! Let me experiment with that and see if that works.
  • m

    Murder Chicken

    04/23/2023, 2:11 PM
    Progress! I think you're onto something @Skye . Thank you!
  • s

    Skye

    04/23/2023, 2:12 PM
    Great
  • d

    dave

    04/23/2023, 11:19 PM
    Copy code
    Trace: CompileError: WebAssembly.instantiate(): Wasm code generation disallowed by embedder
    Am I not allowed to do this?
    Copy code
    typescript
    await initialize(fetch("https://unpkg.com/svg2png-wasm/svg2png_wasm_bg.wasm"));
  • e

    Erisa | Support Engineer

    04/23/2023, 11:38 PM
    Yeah thats blocked, WASM has to be included with the worker
  • d

    dave

    04/24/2023, 12:30 AM
    awww
  • i

    Ivy Wen

    04/24/2023, 3:32 AM
    How to solve the problem of sending agents and being walled
  • c

    conqr

    04/24/2023, 4:23 AM
    MongoDB Realm "performance and speed" 🤡
  • s

    sameerali

    04/24/2023, 5:36 AM
    what does
    wrangler publish
    use to build the typescript app before uploading? is it esbuild?
  • h

    HardAtWork

    04/24/2023, 6:30 AM
    Yes
  • a

    Akarys

    04/24/2023, 3:02 PM
    We're on Bundled, how come it goes above 50ms?
  • a

    Akarys

    04/24/2023, 3:03 PM
    I mean, I am not complaining
  • a

    Akarys

    04/24/2023, 3:03 PM
    can it just "be maybe killed if we need the resources" after 50ms?
  • j

    James

    04/24/2023, 3:04 PM
    pretty much. It's a little variable to allow for spikes and such
  • w

    Walshy | Pages

    04/24/2023, 3:13 PM
    it's done in buckets
  • w

    Walshy | Pages

    04/24/2023, 3:13 PM
    So you can go over if other requests are under
  • w

    Walshy | Pages

    04/24/2023, 3:13 PM
    As long as you're on average below, you're good
  • s

    Sean Mitchell

    04/24/2023, 4:20 PM
    Both from a CF workers perspective as well as an architecture design, how would you recommend implementing a tracker for number of requests per second
  • s

    Sean Mitchell

    04/24/2023, 4:21 PM
    Maybe expiring KV keys? I have been playing with a workers / kv project lately. https://hottakesdictionary.com/
  • k

    kian

    04/24/2023, 4:21 PM
    Depends what your requirements are - KV comes with eventual consistency and writes-per-second constraints, DO comes with strong consistency but latency because of that global uniqueness, etc
  • k

    kian

    04/24/2023, 4:21 PM
    DOs is the usual go-to
  • u

    Unsmart | Tech debt

    04/24/2023, 4:23 PM
    #981314061268578304 would be the way I go for tracking requests 🤔
  • u

    Unsmart | Tech debt

    04/24/2023, 4:23 PM
    Although I guess not suitable for displaying stats publicly given extreme rate limiting on read end
  • s

    Sean Mitchell

    04/24/2023, 4:27 PM
    Interesting, haven't looked at this before. I might just avoid it and try to keep my project currently scoped to KV, DO, and Pages with Functions
  • s

    Sean Mitchell

    04/24/2023, 4:27 PM
    Its already a lot of moving parts, my first app from ground up using CF only
1...241224132414...2509Latest