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

    Greg Brimble | Cloudflare Pages

    11/24/2021, 2:24 PM
    Maybe Netlify do their _redirects before their functions? I'm not really understanding what's going on there.
  • i

    Isaac McFadyen | YYZ01

    11/24/2021, 2:28 PM
    I'm not sure they are actually parsing the _redirects file there (just copying to build dir). Think you might be right about them doing redirects before functions.
  • i

    Isaac McFadyen | YYZ01

    11/24/2021, 2:28 PM
    I'll do some testing on my end and see if I can get _redirects working without breaking everything. 🙂
  • i

    Isaac McFadyen | YYZ01

    11/24/2021, 3:20 PM
    So after some further testing, it seems that the method of just sending a request without checking if it exists messes everything up.
  • i

    Isaac McFadyen | YYZ01

    11/24/2021, 3:20 PM
    Not sure why quite yet, but sometimes my styles break, images are lost, and
    _redirects
    still don't work anyway.
  • s

    Shyamin

    11/24/2021, 4:15 PM
    worker execute without any issues and the hello world works fine
  • s

    Shyamin

    11/24/2021, 4:15 PM
    even in this function the success json is showing when I request
  • u

    0xDamian

    11/24/2021, 5:13 PM
    @Greg Brimble | Cloudflare Pages Sorry for asking bothering you and asking you directly. When creating a worker is it the same like creating a worker on a browser or NodeJS? So does each function create a new worker or is it bundled into one main worker? I'm thinking about it because I don't know how to structure it.
  • g

    Greg Brimble | Cloudflare Pages

    11/24/2021, 5:14 PM
    Are you talking about adding files to the
    functions
    directory?
  • u

    0xDamian

    11/24/2021, 5:22 PM
    Yes, I don't know if I should do functions or workers. Would it be a good idea to use mongoDB in the functions folder or is it better to create a worker specially for the database connection?
  • g

    Greg Brimble | Cloudflare Pages

    11/24/2021, 5:32 PM
    Personal preference, really. If you want to handle routing in a way that’s different to what we give you with the functions dir, then use _worker.js. Otherwise, you’re more than okay to use the functions dir.
  • g

    Greg Brimble | Cloudflare Pages

    11/24/2021, 5:33 PM
    We’re generally advising _worker.js for people who already have Workers that they just want to move, or for framework authors.
  • i

    Isaac McFadyen | YYZ01

    11/24/2021, 5:45 PM
    Also function cross-communication is in beta (services) still, right?
  • i

    Isaac McFadyen | YYZ01

    11/24/2021, 5:45 PM
    You would have to use
    fetch()
    , I think?
  • i

    Isaac McFadyen | YYZ01

    11/24/2021, 5:46 PM
    Are you referring to a function that calls the database? Or a function that is called from another function, that handles database access only?
  • u

    0xDamian

    11/24/2021, 6:34 PM
    That's the question, I don't know if I should use a dedicated worker to just handle the database, because this won't be changed all the time and will be updated once in a while where the normal functions on pages would be constantly upgraded. So the worker that connects with the database would have the Realm key and work as a controller for the database.
  • i

    Isaac McFadyen | YYZ01

    11/24/2021, 6:36 PM
    Hmm... good point. Keep in mind that Pages functions would be version-controlled, which is really nice for rollbacks. Regular workers aren't. Also, depends if you want to seperate your project assets like that. Just some thoughts.
  • t

    tylerb

    11/24/2021, 6:40 PM
    Couldn’t find a size limit in the Pages Functions docs. Imagine it’s 1MB combined (same as Workers)?
  • g

    Greg Brimble | Cloudflare Pages

    11/24/2021, 6:54 PM
    Correct. Same as your Workers account.
  • t

    tylerb

    11/24/2021, 6:56 PM
    Thanks Greg! Sorry if I missed it amongst the flurry of announcements last week, but was there an announcement re: an increase to the Workers script size limit?
  • g

    geelen

    11/24/2021, 7:02 PM
    an increase is coming just not quite yet, I believe you can request an increase much more easily now tho
  • u

    0xDamian

    11/24/2021, 7:05 PM
    So the functions folder can't exceed 1MB or the whole Page is max 1MB?
  • w

    Walshy | Pages

    11/24/2021, 7:07 PM
    The final compiled gzipped script cannot exceed 1MB. There isn't really a great way to measure this
  • u

    0xDamian

    11/24/2021, 7:07 PM
    Final combined script, functions aka worker or the JS script for the frontend? I need a more precise answer.
  • u

    0xDamian

    11/24/2021, 7:08 PM
    For me a script is what I add to my HTML
  • w

    Walshy | Pages

    11/24/2021, 7:08 PM
    The compiled functions. The static assets them self have an individual limit of 25MB (so index.html cannot exceed 25MB).
  • u

    0xDamian

    11/24/2021, 7:10 PM
    The mongo serverless function has 268.1KB
  • u

    0xDamian

    11/24/2021, 7:11 PM
    My idea was to have a separate worker for ONLY the MongoDB Realm cluster, like a controller. Then use multiple databases on that cluster and then with demand (performance) create separate clusters for databases that need it.
  • u

    0xDamian

    11/24/2021, 7:11 PM
    So 3 projects/apps would connect to that mongo worker
  • u

    0xDamian

    11/24/2021, 7:12 PM
    But each of the project would have their own functions to handle the queries but the mongo worker would be basically a CRUD api
1...192021...392Latest