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

    Renoir dos Reis

    02/02/2023, 2:38 AM
    👋 Hello everyone, How can I troubleshoot/debug a Cloudflare Pages function? How to get the logs to see console.logs or anything similar? Im having such a bad experience developing in a attempt and failure workflow.
  • r

    Renoir dos Reis

    02/02/2023, 2:42 AM
    Even after updating my wrangler CLI client I don't have any clue on how to get logs from functions. How did you achieved it?
  • z

    zsmooth

    02/02/2023, 3:18 AM
    It’s in the UI (go the the latest deploy, functions tab) or with wrangler cli. (Something like “wrangler pages logs”)
  • j

    JustinNoel

    02/02/2023, 11:08 AM
    In the Cloudlflare Dashboard, you can go to you Pages section. Then, click on "View Details" for whichever deployment you're interested in seeing logs for. Then, on the "Functions" tab, you'll see the "Real-time Logs". Also, you can tail the logs from your local terminal like: > wrangler pages deployment tail See https://developers.cloudflare.com/workers/wrangler/commands/#tail
  • r

    Renoir dos Reis

    02/02/2023, 1:38 PM
    I tried with those two alternatives, but none of them logged my
    console.debug
    or
    console.log
  • p

    Plotzes

    02/02/2023, 10:28 PM
    This invocation counter on free plan is not accurate, it's missing cron triggers invocations. This is how it looks on the Pages part of dashboard:
  • p

    Plotzes

    02/02/2023, 10:28 PM
    This is how it looks on the Workers part of the dashboard:
  • s

    Skye

    02/02/2023, 10:32 PM
    @Walshy | Pages ^
  • w

    Walshy | Pages

    02/02/2023, 10:32 PM
    yup we know about the difference
  • p

    Plotzes

    02/02/2023, 10:34 PM
    ah great 👍
  • m

    Marcelino Franchini

    02/03/2023, 10:40 AM
    My use case of Pages Functions is very similar to this but not at their scale, what will happen if our project grows? Will we be banned for serving too much JSON? https://news.ycombinator.com/item?id=34639212
    v
    k
    +2
    • 5
    • 7
  • n

    nik1231

    02/05/2023, 2:28 PM
    hello, I'm new one in cloudflare pages, I deployed sveltekit site on free plan, and I saw this limit 100k for workers and functions per day. Its a very light landing page. I saw that this usage of workers increasing after every visit. If I saw good, I can switch on paid plan, and for 5$ I will get 10M requests per month? My site will be under high traffic for one month during campagna, so I want to be sure it will not hit limits and be unavailable. Just to confirm that this is suitable for me.
  • z

    zegevlier

    02/05/2023, 3:21 PM
    Yup, if you're expecting more function invocations than 100k per day, you should upgrade to workers paid. You could also see if you can statically render your site instead.
  • n

    nik1231

    02/05/2023, 4:14 PM
    I guess prerendering invokes functions? I have some posts with md files.. but 5$ for 10M is cheap and I think it will be enough.. And cloudflare pages can handle for example 100,000 unique visitors per day without problems?
  • p

    Plotzes

    02/05/2023, 4:15 PM
    yeah definitely, cloudflare can basically handle anything xD
  • s

    Skye

    02/05/2023, 4:15 PM
    Prerendering sounds like it's done at build time, rather than SSR?
  • s

    Skye

    02/05/2023, 4:15 PM
    But yeah, pages will scale to whatever you can throw at it
  • n

    nik1231

    02/05/2023, 4:18 PM
    is there any log or similar where I can check what is using those functions?
  • e

    Erisa | Support Engineer

    02/05/2023, 6:32 PM
    you cant check historical but you can stream the current logs
  • z

    zszszsz

    02/07/2023, 2:33 AM
    Would there be 3rd party logging service you might recommend ?
  • z

    zszszsz

    02/07/2023, 2:34 AM
    eg. sth like aws cloudwatch where a worker can send logs to
  • z

    zszszsz

    02/07/2023, 2:37 AM
    CloudWatch works great from my experience but would you cf guys recommend sth else ?
  • j

    JustinNoel

    02/07/2023, 12:10 PM
    I use LogFlare. It's pretty nice for real-time stuff. LogFlare automatically saves all my logs in my own BigQuery bucket so I can do in-depth troubleshooting and data mining. FYI: Supabase bought it a while back and now is integrating it into their service. https://logflare.app
  • z

    zszszsz

    02/07/2023, 5:08 PM
    Is it possible to send console outputs of a specific pages project via the logflare cf app ?
  • z

    zszszsz

    02/07/2023, 5:12 PM
    Hmm the webhook endpoint looks good, but the apps seems not so useful for this case
  • c

    cxres

    02/07/2023, 7:04 PM
    Sorry for repeating the question here... I am defining a functions file
    /functions/profile/index.js
    with
    export async function onRequest
    . I have also defined a
    _routes.json
    . However, when I run
    wrangler pages dev myproject/
    I get the message
    No functions. Shimming...
    Please Help!
  • v

    Vero 🐙

    02/09/2023, 12:16 PM
    Hey @zszszsz Logflare, despite the name, is not a thing Cloudflare owns. It's a third-party service. We can't really help debugging that. So, our recommendation is to look at wrangler pages deployment tail for any debugging of `console.log()`s.
  • v

    Vero 🐙

    02/09/2023, 12:17 PM
    Hi @cxres Sounds like you're probably running Wrangler from the wrong directory. You should run
    wrangler pages dev
    in the root of your project, and the
    functions/
    directory should be a child of that root.
  • v

    Vero 🐙

    02/09/2023, 12:33 PM
    Hey @sudokar You can do auth(n|z) with Functions, yes, but to do it yourself from scratch would be a chunk of work. I would recommend using a third-party. I think Supabase Auth is currently pretty popular. Nothing quite like AWS API Gateway, but you can do a bunch of cool routing stuff with one Worker acting as a gateway and using Service Bindings to other Workers.
  • z

    zszszsz

    02/09/2023, 5:36 PM
    Yeah I know it is 3rd party. However the tail is really not enough. Like if the problem is hard to reproduce (or if it just happens randomly) it is better to write logs constantly so you can look at history logs. And if it is for analysis purpose you would need a lot of logs for a really long period. I don't think you guys would recommend running wrangler tail as a daemon service somewhere right.
1...342343344...392Latest