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

    yamiteru

    04/06/2023, 1:46 PM
    Are there any plans to locally expose services such as R2 so they have a local URL?
  • d

    dave

    04/06/2023, 2:07 PM
    what do you mean by local URL?
  • y

    yamiteru

    04/06/2023, 2:16 PM
    Well when you create R2 bucket in the Dashboard you get a public URL that you can use (for example for creating signed URLs). Currently miniflare/wrangler doesn't expose such local URL even though they provide an API for local development (which means somewhere behind the scenes the R2 bucket is actually getting "simulated" so it should be trivial to expose it).
  • h

    HardAtWork

    04/06/2023, 2:20 PM
    Not really. The thing that wrangler/Miniflare emulates is the R2 Workers API, which is missing a lot of the pieces that makes the public bucket tick
  • h

    HardAtWork

    04/06/2023, 2:23 PM
    You could probably emulate R2 with a local hosted S3-compatible storage system(Minio maybe)
  • a

    anurag

    04/06/2023, 5:15 PM
    When I run Cloudflare worker locally using
    wrangler dev
    where does it get the KV data from? Earlier I thought and noticed that it's storing the data on the actual edge that I could see on the CF dashboard but now there's a difference between the data in the KV on the dashboard and what I'm getting during local development.
  • a

    anurag

    04/06/2023, 5:17 PM
    oh my bad the "Preview" thing
  • j

    James

    04/06/2023, 5:17 PM
    With
    wrangler dev
    , if you use
    —local
    , it’s entirely local, either in memory, or to disk if you also add
    —persist
    . If you don’t, it’ll use real KV via whatever ID you use in the
    preview_id
    in your
    wrangler.toml
  • a

    anurag

    04/06/2023, 5:19 PM
    Okay, then what's the difference between the
    preview_id
    KV and the normal
    id
    ?
  • j

    James

    04/06/2023, 5:19 PM
    Preview ID is used in dev. Normal ID is used when you publish it
  • a

    anurag

    04/06/2023, 5:20 PM
    Got it then what'd be the use case for
    --local
    like when should someone use it?
  • j

    James

    04/06/2023, 5:22 PM
    —local is great for purely local dev, if the cf network is down, your connection is spotty, or you just don’t want to wait on network requests and want things to be faster and entirely run locally on your machine
  • a

    anurag

    04/06/2023, 5:26 PM
    Got it. My use case is a bit complicated. I'm using Postgres Triggers to update values in the KV so if I run it entirely locally, I'll have to change the webhook URL for local and staging env. I'm already using CF tunnel but it'd be a bit tedious to change the values. But thank you for answering the questions, James 🫡
  • h

    HardAtWork

    04/06/2023, 6:11 PM
    @bulk88, moved from #917505178016579605, how are you deriving your data?
  • s

    sameerali

    04/06/2023, 8:40 PM
    is there anyway to increase sub-request limit on worker?
  • h

    HardAtWork

    04/06/2023, 8:41 PM
    Switch to Unbound
  • s

    sameerali

    04/06/2023, 9:13 PM
    Thanks. unbound has no limit?
  • s

    Skye

    04/06/2023, 9:14 PM
    1000
  • s

    Skye

    04/06/2023, 9:14 PM
    As opposed to 50
  • s

    sameerali

    04/06/2023, 9:14 PM
    Thanks so much
  • j

    jschlesser

    04/06/2023, 11:38 PM
    When i try to run wrangler locally with --test-scheduled it throws the following error
    [mf:err] TypeError: Cannot read properties of undefined (reading 'middleware')
    . Has anyone else run into this?
  • j

    jschlesser

    04/07/2023, 12:16 AM
    npm install wrangler@latest
    fixed it. Recent bug fix
  • a

    autoxins

    04/07/2023, 2:42 AM
    Does the
    Request
    object in Cloudflare Worker not support the
    tee()
    method??
  • k

    kian

    04/07/2023, 3:01 AM
    Request.body.tee()
  • k

    kian

    04/07/2023, 3:01 AM
    tee()
    is implemented on ReadableStreams - and that's the
    body
    property
  • a

    Arnø

    04/07/2023, 5:31 AM
    Hello, have you find a solution ? I also try to send push notifications from a worker
  • p

    presently

    04/07/2023, 6:20 AM
    Hi, I'm a bit new to CF and JS. It is my understanding that
    env
    is not available in the global 'scope' (?) when using modules syntax. Thus, this code which accesses
    env
    from a function doesn't work.
    Copy code
    js
    
    async function listFiles() {
      const fileList = await env.MY_BUCKET.list()
      return new Response('Ok')
    }
    
    export default {
      async fetch(request, env) {
        return await listFiles()
      },
    }
    Is there any way to get around that other than just passing
    env
    to
    listFiles()
    ? I'm fine doing that but it seems tedious for the half dozen or so functions I'm making. Maybe there is some JS trick to make
    env
    be accessible in its child functions. Edit: I guess you can move the functions so they have access to the scope where
    env
    is hiding.
    Copy code
    js
    export default {
      async fetch(request, env) {
        return await listFiles()
        async function listFiles() {
          const fileList = await env.MY_BUCKET.list()
          return new Response('Ok')
        }
      },
    }
    Works for me, probably won't change it unless I'm told it's really bad practice for some reason.
  • t

    Tom Sherman

    04/07/2023, 8:08 AM
    Explicit passing is probably a good thing 😅
  • t

    Tom Sherman

    04/07/2023, 8:09 AM
    With node compat you can probably put these into AsyncContext to avoid having to pass them down manually
  • c

    Code6

    04/07/2023, 12:56 PM
    Yes, I found @K0IN 's repository, which supports sending push notifications from CF https://github.com/K0IN/Notify
1...238023812382...2509Latest