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

    Erisa | Support Engineer

    12/18/2021, 11:06 PM
    I had thought it would only fire for the function routes but I think currently its all requests, sorry
  • e

    Erisa | Support Engineer

    12/18/2021, 11:06 PM
    I hope that changes at some point
  • s

    Skye

    12/18/2021, 11:33 PM
    yeah this is not ideal for my current app
  • s

    Skye

    12/18/2021, 11:34 PM
    it loads a lot of different assets and I can't have those counting for code I'm not actually running
  • e

    Erisa | Support Engineer

    12/19/2021, 12:18 AM
    Does anyone know if this is going to change in future?
  • g

    Greg Brimble | Cloudflare Pages

    12/19/2021, 12:25 AM
    You will not be charged for simply serve static assets.
  • g

    Greg Brimble | Cloudflare Pages

    12/19/2021, 12:25 AM
    We haven't figured out the best way to do that just yet, but we won't GA until we have a good solution.
  • w

    Walshy | Pages

    12/19/2021, 12:18 PM
    Pages will natively basically cache assets on edge without any config, you wouldn't need to do anything special 😉 (and yes, for pages.dev or custom)
  • r

    richardwong

    12/19/2021, 12:23 PM
    Thanks for your reply
  • s

    Stew

    12/19/2021, 12:26 PM
    I just checked mine again now, you're completely right! I've deleted that comment so it doesn't confuse anyone if they're searching on the discord and don't' see your reply. Apologies, I was doing a bunch of testing yesterday with remix/sveltekit on workers and pages and must have got something mixed up
  • s

    Stew

    12/19/2021, 12:28 PM
    Is it detailed anywhere what the permitted execution time is for a pages function? I know for normal workers it depends if it's bundled/unbound, but page functions runs on workers anyway and best I can find is a generic daily limit.
  • w

    Walshy | Pages

    12/19/2021, 12:30 PM
    I believe it'll follow your Worker plan, so if paid 50ms otherwise 10ms but I may be wrong
  • s

    Stew

    12/19/2021, 12:37 PM
    Ah so if I have any use cases for unbound workers, I'll need to package/deploy them separately. I guess having the ability to include bundled/unbound in one repo/deploy will be something after GA (assuming you're right)
  • t

    taro

    12/21/2021, 7:41 PM
    apologies for jumping the gun here a bit, but is there any iteration of wrangler2 that allows binding DOs to
    wrangler pages dev
    instances?
  • t

    taro

    12/21/2021, 7:43 PM
    currently trying to bind a simple toy DO using
    wrangler@alpha
    and
    wrangler pages dev <STATIC_FOLDER> -o COUNTER=Counter
  • t

    taro

    12/21/2021, 7:44 PM
    i've also tried binding it several other ways, eg
    -o COUNTER=Counter@example-worker-script-name
  • t

    taro

    12/21/2021, 7:45 PM
    I can successfully publish the DO using
    wrangler publish <WORKER_SCRIPT_FILE_PATH>
    and test the worker as expected
  • t

    taro

    12/21/2021, 7:46 PM
    additionally, I can bind the DO to the prod/preview envs in the pages dashboard
  • g

    Greg Brimble | Cloudflare Pages

    12/21/2021, 8:28 PM
    wrangler@pages
    is a WIP on external durable objects support.
  • g

    Greg Brimble | Cloudflare Pages

    12/21/2021, 8:28 PM
    We're still figuring out the interface we want to expose. Suggestions are welcome!
  • t

    taro

    12/21/2021, 8:32 PM
    okay I figured it out!
    wrangler@pages
    is required,
    wrangler@alpha
    is incompatible with DOs as of this moment (in the dev env)
  • t

    taro

    12/21/2021, 8:32 PM
    the specific working
    wrangler@pages
    version im using is
    0.0.0-6e68a3b
  • t

    taro

    12/21/2021, 8:53 PM
    so regarding feedback, its an ever so slight annoyance to perform path diffing between nested/deeper
    functions
    and DOs they
    fetch
    from. For example, I have a function at
    functions/api/counter
    which passes untouched/original requests to a
    Counter
    DO. That DO is just a quick copy-paste of the
    Counter
    example from the DO docs, which only responds with anything of substance to requests at the "root" level, e.g.
    /increment
    . Since this is the case, if I make a call to my pages app at
    /api/counter/increment
    , I have to properly slice the request's path before passing it to the DO (the DO doesn't handle anything at
    /api/...
    ). Of course, there are a handful of ways to address this (DOs can handle entire/absolute paths vs. relative, absolute paths can be made relative, etc.), but they all roughly have the same drawback of maintaining similar/duplicate route matching within both
    functions
    and DOs; i.e. I have to maintain two instances of route matching/handling in order to fully serve requests to
    /api/counter/increment
  • t

    taro

    12/21/2021, 8:54 PM
    If I had to guess, maintaining this similar/duplicate route matching can eventually become cumbersome in larger codebases.
  • t

    taro

    12/21/2021, 8:56 PM
    this might also just be a big nothingburger 😅
  • g

    geelen

    12/21/2021, 9:26 PM
    I know Sunil's been tossing around the idea of having a
    filename.durable.ts
    scheme that automatically get bundled up into a DO, I suppose that could work for file-based routing...
  • g

    geelen

    12/21/2021, 9:27 PM
    > For example, I have a function at functions/api/counter which passes untouched/original requests to a Counter DO IMO this is the bit that should change though—we should have an RPC-style way of calling
    env.MY_OBJECT.increment()
    instead of
    .fetch
  • g

    geelen

    12/21/2021, 9:28 PM
    then your DO can start to feel like a real Object rather than a kind of "stateful worker"
  • r

    richardwong

    12/22/2021, 5:05 AM
    Hi, can we use HtmlRewriter api in functions ?
  • h

    HardAtWork

    12/22/2021, 5:06 AM
    Yes
1...474849...392Latest