https://discord.cloudflare.com logo
Join Discord
Powered by
# functions
  • z

    zszszsz

    04/23/2023, 10:03 PM
  • z

    zszszsz

    04/23/2023, 10:04 PM
    I am pretty sure this is the wrangler pages dev one. See that total cpu time
  • z

    zszszsz

    04/23/2023, 10:05 PM
    But what would it build if I already provided a _worker
  • z

    zszszsz

    04/23/2023, 10:10 PM
    This dies after I kill wangler but won't die after I kill my build watch one.
  • z

    zszszsz

    04/23/2023, 10:43 PM
    It looks like, whenever I overwrite _workers.js with
    wrangler pages dev
    running, the number becomes larger.
  • z

    zszszsz

    04/23/2023, 10:44 PM
    The command is just
    npx wrangler pages dev ./dist
    and nothing more.
  • z

    zszszsz

    04/23/2023, 10:46 PM
    And everything will be back to normal after I restart wrangler.
  • z

    zszszsz

    04/23/2023, 10:49 PM
    It is wrangler 2.16.0
  • z

    zszszsz

    04/23/2023, 10:50 PM
    (It is a bit cold after I killed wrangler 😦 )
  • l

    Larry

    04/24/2023, 3:28 AM
    What about as a producer? I see how you can use it as a producer in the Dashboard but not when using
    wrangler pages dev
  • g

    Gradyent

    04/24/2023, 1:12 PM
    It seems like Service bindings are supported in prod, but not when running locally because https://github.com/cloudflare/workers-sdk/pull/2162 isn't merged. Is that right? How do people develop Functions with Service bindings in practice? Are there workarounds?
  • s

    Skye

    04/24/2023, 1:14 PM
    That's right, there's not any nice way of testing it locally at the moment
  • r

    robinmetral

    04/25/2023, 9:16 PM
    Hi! If anyone has a successful local setup for using D1 in Pages Functions, I'd love your help: https://community.cloudflare.com/t/working-with-d1-and-cloudflare-pages-in-local-development/501863
  • b

    BenSeitz

    04/26/2023, 4:50 PM
    I'm having the same problem right now. https://blog.cloudflare.com/whats-new-with-d1/ tells us, that it's possible to download a d1 backup and use that locally. I just tried that and it works well. I run
    wrangler pages dev ./public --d1=DB_BINDING --persist
    This creates a
    .wrangler/state/d1/DB_BINDING.sqlite3
    file. I replaced that with the backup. I don't know if there's a shortcut somehow...
  • r

    robinmetral

    04/26/2023, 9:49 PM
    This is great—thank you! This part of the article is also very helpful: "Or you can simply use SQLite directly with the SQLite command line by running `sqlite3 .wrangler/state/d1/DB.sqlite3`". So basically the recommendation is to avoid things like
    wrangler d1 execute <command>
    and interface directly with the local SQLite file.
  • r

    robinmetral

    04/26/2023, 9:52 PM
    For what it's worth: apparently, even though not officially supported for Pages,
    wrangler d1 execute --local <command>
    will work if the binding is defined in wrangler.toml. So that is also kind of working for me. I'll update https://community.cloudflare.com/t/working-with-d1-and-cloudflare-pages-in-local-development/501863 with details!
  • s

    spacey

    04/27/2023, 2:14 AM
    I have a simple static pages with a form and a single simple function to save the form post data to the kv store. this requires me to have 1. astrobuild auto build on file changes (static site) 2. wrangler local backend I'm using the following command sine the docs are lacking i had to figure this out is this correct (works for me) wrangler pages dev --proxy=3000 --live-reload=true --persist=true --experimental-local=true --compatibility-date=2023-04-26
  • s

    spacey

    04/27/2023, 2:24 AM
    also now that its working how do use the command
    npx wrangler kv:key list
    with this local kv store?
  • s

    spacey

    04/27/2023, 6:23 AM
    --persist should be default why all this added complexity. I'm giving up on KV local dev (could not find a single updated doc) will try D1.
  • v

    vendettabass

    04/27/2023, 7:35 AM
    anyone ever had to parse a string of yaml (from a
    Response
    , not a file) to json in a worker / function?
  • h

    HardAtWork

    04/27/2023, 7:41 AM
    https://www.npmjs.com/package/yaml should work fine: https://cloudflareworkers.com/#5bd33710458c37e6786b78f41283febe:https://tutorial.cloudflareworkers.com/
  • v

    vendettabass

    04/27/2023, 8:35 AM
    thanks, I'm not sure how to use that package inside a CFP function, I'm seeing (when I try to deploy to Pages) > ✘ [ERROR] 1 error(s) and 0 warning(s) when compiling Worker. > ✘ [ERROR] Could not resolve "yaml" am I missing something from your second link?
  • h

    HardAtWork

    04/27/2023, 8:36 AM
    Did you install the package? Are you using Advanced Mode?
  • v

    vendettabass

    04/27/2023, 8:37 AM
    ah, I'm not, I'll take a look
  • v

    vendettabass

    04/27/2023, 8:39 AM
    will my _middleware in
    /functions
    still work if I switch out to using
    _worker.js
    ?
  • w

    Walshy | Pages

    04/27/2023, 8:40 AM
    No but you don't need to use advanced mode, that was just to see if you were bundling If you install the package, you should be good to go
  • v

    vendettabass

    04/27/2023, 8:43 AM
    thx @Walshy | Pages
  • s

    silentdevnull

    04/27/2023, 9:30 PM
    So I'm trying to list all of the directory in the root of my R2 bucket. I followed along with a few different examples and I can't seem to get it to work. I did the binding as the documentation told me to.
    Copy code
    export async function onRequest(context) {
    
        const options = {
            limit: 500,
            include: ['customMetadata'],
        };
        
        const obj = await context.env.NAME.list(options);
        if (obj === null) {
            return new Response('Not found', { status: 404 });
        }
        return new Response(obj.body);
    }
    This is my first time trying to do R2 through code so I could be something simple I'm missing.
  • k

    kian

    04/27/2023, 9:30 PM
    body
    is for
    GET
  • k

    kian

    04/27/2023, 9:30 PM
    you're listing so there is no bodies
1...376377378...392Latest