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

    Skye

    04/17/2023, 1:41 PM
    the finally block would never run
  • j

    jed

    04/17/2023, 1:41 PM
    it does in fact execute if it's synchronous... is that the difference?
  • j

    jed

    04/17/2023, 1:41 PM
    that's not true, though.
  • j

    jed

    04/17/2023, 1:41 PM
    finally always runs.
  • s

    Skye

    04/17/2023, 1:42 PM
    Oh🤔
  • s

    Skye

    04/17/2023, 1:42 PM
    I admittedly haven't used it, assumed it worked similarly to a catch
  • s

    Skye

    04/17/2023, 1:43 PM
    But yeah in the workers runtime, I'm pretty sure it'd end as soon as the response returns unless you use waituntil
  • p

    paras

    04/17/2023, 1:43 PM
    Thanks, though how would I go about setting up KV namespaces and Ids that the app depends on?
  • s

    Skye

    04/17/2023, 1:43 PM
    I don't know of anyone receiving this yet
  • j

    jed

    04/17/2023, 1:44 PM
    but again, this is not true.
  • j

    jed

    04/17/2023, 1:44 PM
    it'll log after returning a response.
  • s

    Skye

    04/17/2023, 1:44 PM
    Have you done asynchronous work with it?
  • j

    jed

    04/17/2023, 1:44 PM
    not yet, i'm wondering if that's the difference.
  • s

    Skye

    04/17/2023, 1:44 PM
    Because waitUntil is specifically for async work - the types even only say it takes a promise
  • k

    Kartik

    04/17/2023, 1:45 PM
    From the dashboard
  • k

    Kartik

    04/17/2023, 1:45 PM
    they can create the kvs and all from the dashboard and then use those credentials in the config file
  • j

    jed

    04/17/2023, 1:46 PM
    Copy code
    export default {
      async fetch(request, env) {
        try {
          console.log('try')
          return new Response("Hello world") 
        }
    
        finally {
          await new Promise(x => setTimeout(x, 1000))
          console.log('async finally')
        }
      }
    }
    this still logs in the finally block.
  • k

    kian

    04/17/2023, 1:48 PM
    That's just going to block your Response
  • k

    kian

    04/17/2023, 1:49 PM
    Set it to 5 seconds and you're not getting
    Hello world
    until 5 seconds passes
  • k

    kian

    04/17/2023, 1:49 PM
    waitUntil
    is fully non-blocking
  • j

    jed

    04/17/2023, 1:49 PM
    oh interesting.
  • j

    jed

    04/17/2023, 1:49 PM
    that answers my question.
  • j

    jed

    04/17/2023, 1:50 PM
    so from a billing perspective they're the same, but the
    finally
    version blocks the response.
  • j

    jed

    04/17/2023, 1:50 PM
    thanks, @kian!
  • k

    kian

    04/17/2023, 1:51 PM
    Yeah, duration is duration so you'd see no difference in billing
  • k

    kian

    04/17/2023, 1:51 PM
    All
    waitUntil
    does is let you return a Response and gives you 30 seconds to have the passed Promises resolve
  • k

    Kevin W - Itty

    04/17/2023, 2:17 PM
    When we get a surprise bill, how can we track down which Worker caused the damage?
  • k

    Kevin W - Itty

    04/17/2023, 2:19 PM
    Spot checking each Worker individually is both tedious and ultimately fruitless (as we can only see the prev 7 days in the dash)... would love the equivalent of DaisyDisk to explore/dig deeper, or even just a flat table of read/write requests/mo for each active Worker.
  • k

    kian

    04/17/2023, 2:22 PM
    Copying the GraphQL calls that the dashboard makes & just changing the date range lets you go beyond 7 days
  • k

    kian

    04/17/2023, 2:22 PM
    As to why the graphs only go back 7 days if the data is retained for longer,
1...240024012402...2509Latest