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

    Erwin

    04/20/2022, 9:00 AM
    Damn.. that is a good catch.. I read the code multiple times and didn't notice the missing braces..
  • k

    kian

    04/20/2022, 9:02 AM
    Took me a few passes till I figured it out haha
  • e

    Erwin

    04/20/2022, 9:47 AM
    We do not generally give dates when things are available. There functions themselves are rock solid, but there is a ton of the (boring) work that needs to be done like billing etc. But we do increase the functions limit if you want to use them already?
  • o

    oldschoolcurry

    04/20/2022, 11:26 AM
    You are the best, thanks!
  • k

    kian

    04/20/2022, 11:35 AM
    the parameter passed to the onRequest functions is a “context” object which contains request, env, params, etc
  • k

    kian

    04/20/2022, 11:36 AM
    since you just want the request you can access just that with the curly brackets
  • o

    oldschoolcurry

    04/20/2022, 11:38 AM
    Ok thanks 😃
  • o

    orstavik77

    04/20/2022, 1:26 PM
    Does the wrangler.toml settings work in a cloudflare pages project?? I run the wrangler2 (beta) command > npx wrangler pages dev ./public with the following wrangler.toml file > compatibility_date = "2022-04-20" > compatibility_flags = ["formdata_parser_supports_files"] But this doesn't seem to work? When a worker gets an image file sent in from a form, and processes it like this: > export async function onRequestPost({request}) { > try{ > const data = await request.formData(); > const file = data.get("file"); > console.log(typeof file); > ... it prints "string". Because the formData() still returns a string. How should I set the compatibility_... to get this right?
  • o

    orstavik77

    04/20/2022, 1:28 PM
    Do I have to pass in compatibility to the wrangler pages dev locally? And where do I set these compatibility things in the pages project on the server?
  • j

    James

    04/20/2022, 1:35 PM
    Unfortunately you can’t today, from my knowledge. Functions doesn’t pass any compat flags and there isn’t a way to set them today
  • o

    orstavik77

    04/20/2022, 1:36 PM
    Auch.. :(
  • o

    orstavik77

    04/20/2022, 1:37 PM
    Thanks for confirming my worst fear.
  • o

    orstavik77

    04/20/2022, 1:43 PM
    Does anybody know if this will come soon?
  • j

    James

    04/20/2022, 2:01 PM
    I also hope so, but I don’t know of any eta unfortunately, sorry
  • o

    orstavik77

    04/20/2022, 2:38 PM
    Yeah. I wish we weren't in this boat together.. :)
  • o

    orstavik77

    04/20/2022, 2:43 PM
    But I don't understand why this isn't implemented. I assume that pages are simply throwing all the functions together into a single worker. Adding critical settings such as compatibility should be fairly straightforward, no? Can anyone tell me why this isn't already added?
  • i

    Isaac McFadyen | YYZ01

    04/20/2022, 2:49 PM
    It's not that simple, unfortunately.
  • i

    Isaac McFadyen | YYZ01

    04/20/2022, 2:49 PM
    Compatibility dates are tied to the runtime being used.
  • i

    Isaac McFadyen | YYZ01

    04/20/2022, 2:49 PM
    Currently Functions uses a different V8 runtime configuration while in beta.
  • i

    Isaac McFadyen | YYZ01

    04/20/2022, 2:50 PM
    That's not possible to change at the moment, but the team has an eye on it.
  • o

    orstavik77

    04/20/2022, 3:07 PM
    Yes, of course, nothing in life is that simple:)
  • o

    orstavik77

    04/20/2022, 3:16 PM
    But. On the topic. Can you confirm that conceptually pages functions are that simple? 1. The functions/*.js files are scanned. 2. The scan produces a route. That we can see in the deploy output. 3. And the scanner also produces a list of import statements. 4. And then this route and import statement are glued at the top of a standard worker.js. 5. And then this single worker is "wrangler published". Of course, more details involved, but is this a fair 30sec description of how pages functions turn into a single worker?
  • i

    Isaac McFadyen | YYZ01

    04/20/2022, 3:26 PM
    Yes on points 1 to 3. For point 4, I believe
    esbuild
    is actually used to bundle (not just "glued"). As for the publishing, I believe it's done internally (not with a tool like Wrangler) but conceptually it won't matter for you, as the user.
  • i

    Isaac McFadyen | YYZ01

    04/20/2022, 3:26 PM
    And there's also some more complexity around static assets, because your Functions need to be merged with the internal Worker serving the static assets.
  • o

    orstavik77

    04/20/2022, 3:32 PM
    Nice)
  • o

    orstavik77

    04/20/2022, 3:35 PM
    But I think maybe they are running wrangler to publish.. The deployment / "Build log" says the following: > ... > 09:29:09.190 🚧 'wrangler pages ' is a beta command. Please report any issues to https://github.com/cloudflare/wrangler2/issues/new/choose > 09:29:09.266 Compiled Worker successfully. > ...
  • o

    orstavik77

    04/20/2022, 3:39 PM
    And if they are using wrangler... are you sure that they are using a different v8? That they are not just using a fixed wrangler.toml file, and that the fixed nature of this default wrangler.toml file is the root cause of the constraints on the pages functions workers?
  • i

    Isaac McFadyen | YYZ01

    04/20/2022, 3:53 PM
    So I just verified and it's indeed the same V8 (sorry for the confusion there). Not sure what the blocker for dates/flags are.
  • i

    Isaac McFadyen | YYZ01

    04/20/2022, 3:59 PM
    I can confirm from one of the Pages engineers that it's not related to a fixed wrangler.toml, they just haven't added support yet.
  • g

    Greg Brimble | Cloudflare Pages

    04/20/2022, 4:13 PM
    Pages doesn't pick anything up from wrangler.toml (at the moment—maybe in the future)
1...124125126...392Latest