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

    Scottmas

    05/08/2023, 10:23 PM
    Sorry to bother you again. But one more question I cannot for the life of me find in the documentation: Given a Pages project with
    /functions/blah.ts
    and an asset
    /blah.html
    , how does it determine what gets served with a GET request to
    /blah
    ? HTML takes priority I assume?
  • s

    Skye

    05/08/2023, 10:26 PM
    The function always runs first
  • s

    Scottmas

    05/08/2023, 10:26 PM
    Same with
    /functions/index.ts
    and
    /index.html
    ?
  • s

    Skye

    05/08/2023, 10:28 PM
    It always runs if there's a function for that path
  • s

    Scottmas

    05/08/2023, 10:28 PM
    That also seems less desirable from an inadvertent shadowing perspective. I personally would prefer it if I had to prefix it like you see with Nextjs api routes
  • s

    Skye

    05/08/2023, 10:28 PM
    If there isn't, it goes to redirects, then your files, then headers
  • s

    Scottmas

    05/08/2023, 10:28 PM
    K, so that's the order
  • s

    Scottmas

    05/08/2023, 10:28 PM
    functions, redirects, files, headers
  • s

    Skye

    05/08/2023, 10:28 PM
    Correct
  • s

    Scottmas

    05/08/2023, 10:29 PM
    You should add that somewhere in the docs. In general, an anatomy of what a Pages project should look like and how all the pieces are expected to fit together would be nice
  • s

    Scottmas

    05/08/2023, 10:30 PM
    Nextjs did a nice job of mapping out the routing waterfall on their old /pages documentation if you're looking for inspiration: https://nextjs.org/docs/pages/building-your-application/routing
  • u

    Unsmart | Tech debt

    05/08/2023, 10:36 PM
    I'm really confused where it states the order of routing on that
  • s

    Scottmas

    05/08/2023, 10:39 PM
    I guess just the ordering of the content. And by the end of the entire section, I feel like I have a pretty good feel for the A-Z routing story
  • u

    Unsmart | Tech debt

    05/08/2023, 10:40 PM
    That isnt the order because middleware would run before pages do.
  • b

    Better James

    05/08/2023, 10:40 PM
    It doesn't really, the only place where they have valuable information about the order of what happens is somewhere on the middleware page iirc
  • s

    Scottmas

    05/08/2023, 10:41 PM
    Yeah, that's true
  • u

    Unsmart | Tech debt

    05/08/2023, 10:41 PM
    ah I see there is a somewhat order there, but it doesnt even show api routes in that list haha
  • b

    Better James

    05/08/2023, 10:42 PM
    that's because they're considered the same as any other route on the file system 🙂
  • u

    Unsmart | Tech debt

    05/08/2023, 10:42 PM
    Yeah but the point kind of was if theres an API and a Page with the same route which one wins
  • s

    Scottmas

    05/08/2023, 10:42 PM
    Maybe the biggest difference is that all the information necessary to understand routing is all in one section of their docs. Right now the Pages documentation is broken up across https://developers.cloudflare.com/pages/platform/functions/routing/, https://developers.cloudflare.com/pages/platform/functions/middleware, https://developers.cloudflare.com/pages/platform/headers/, etc
  • s

    Scottmas

    05/08/2023, 10:43 PM
    Anyhow, I'll stop bugging you guys hahaha. Thanks for all you do, seriously
  • b

    Better James

    05/08/2023, 10:43 PM
    I'm not sure that would actually be possible, although defined takes precendence over dynamic/catchall. that's documented somewhere else. you have to go digging to find that kind of valuable info
  • u

    Unsmart | Tech debt

    05/08/2023, 10:43 PM
    Ah yeah youre right its not even possible to have a conflicting route
  • d

    dave

    05/08/2023, 11:27 PM
    Is there a way to estimate the CPU time when running a Worker locally?
  • d

    dave

    05/08/2023, 11:48 PM
    problem solveeeed! Ended up making the AWS access ID a signed JWT token, so you can't brute force email addresses. Did some very fun trickery that shockingly worked out even better than I expected, and perf will be amazing once we add DOs like you 😄
  • b

    biscuit

    05/09/2023, 3:09 AM
    Hello guys, I'm having a bit of a problem with trying to get tensorflow.js working on cloudflare workers. When loading ``tf.loadLayersModel()`` it starts 45 concurrent connections to read all my binary files which are currently stored on r2. This causes "Error: Response closed due to connection limit". I've tried to use the R2 env variable but the function requires a url to be passed into it so it can load the main file (model.json) and the dozens of other binary files contained in the same folder. I've attempted to read them 1 by 1 but at that point the worker timed out barely getting past 35. I've attempted to store them into KV but they are binary files and it seems like i wasnt able to insert them into KV as is. I was thinking of converting the binary into a base64 string to be able to store but that just added another layer of processing which i have no cpu time left for. TLDR Im looking for the concurrent connection limit for r2 to read multiple files in the same folder at the same time, and I'm wondering if its possible to increase the limit somehow or limit it to a couple of concurrent at a time but i have no idea what the limit is. I'm sure combining them would fix the issue but I'm scared I would spend hours on it and get no return after hitting another wall. Is there some other worker function? This is the test code I'm currently using:
    Copy code
    import * as tf from '@tensorflow/tfjs';
    
    async function loadModel() {
      const model = await tf.loadLayersModel('https://custom(r2).domain/models/tfjs_model/model.json');
      return model;
    }
    
    addEventListener('fetch', (event) => {
      event.respondWith(handleRequest(event));
    });
    
    async function handleRequest(event) {
      try {
        const model = await loadModel();
        console.log('Model loaded successfully');
        return new Response('Model loaded successfully', { status: 200 });
      } catch (err) {
        console.error('An error occurred:', err);
        return new Response('An error occurred:'+err, { status: 500 });
      }
    }
  • d

    dave

    05/09/2023, 4:34 AM
    @sathoro you didn't run into rate limiting issues with supabase through Workers?
  • s

    sathoro

    05/09/2023, 4:34 AM
    we barely call Supabase from Workers, the main path is JWT checking which is cached
  • s

    sathoro

    05/09/2023, 4:35 AM
    and nope never seen any errors that have popped up from calling Supabase
  • s

    sathoro

    05/09/2023, 4:35 AM
    we still get a ton of intermittent DO errors though...
1...244624472448...2509Latest