Unexplainable Functions request count


I’ve been using Pages for hosting a static Eleventy website, and so far it’s been great.
Yesterday, I added a Pages Function that subscribes people to my newsletter if they fill in a form.

However, so far today, the function has been invoked 10.000 times. Which is impossible given that my website receives only 2000 visits per day and not every visitor signs up for my newsletter.

At first, I thought this was caused by bots. So I tried:

  1. Adding a Page Rule that increases the security level to high. That didn’t have any impact, the request counter kept increasing.

  2. As no logging is available for Pages Functions, I added some logging myself. Every time the Function is invoked, I send the request object to New Relic. This reveals almost no requests (only test requests that I make).

So my question is: what is causing these “ghost” requests to my Function? At this rate, I’ll blow through half of the free-tier everyday.

The function is stored in this path in my git repo: functions/newsletter/signup.js
Which means it’s accessible through this URL: https://savjee.be/newsletter/signup

The function itself only processes POST requests:

export async function onRequestPost({request, env})
   // 1. Log request to New Relic with "fetch"
   // 2. Call the newsletter API to add a subscriber

The full code of my function is available here: savjee.be/signup.js at master · Savjee/savjee.be · GitHub
(Yes, I realise my API token for New Relic is exposed, but it’s for testing purposes only).

My previous newsletter are also posted on the website and have this URL format: /newsletter/issue/18/
I initially thought that the Function might be wrongly triggered because it’s shares part of the URL. However, these pages don’t get much traffic, and again, I’m not seeing anything come up in New Relic.

Any thoughts? I must be missing something obvious.

Today, if you have any Functions at all in your Pages project, every single request (including those for static assets) count towards your quota. So if those 2000 visits each requested 5 assets (some CSS, JS, images, etc.) you could quickly hit 10,000.

This is obviously not ideal, and something that I know is being worked on at the moment, so that Functions are only hit (and therefore only count towards your quota) where you would expect them to. For a sneak peak of how this might look, check out some of the recent PRs into wrangler2, like https://github.com/cloudflare/wrangler2/pull/1608.

If you’re concerned about hitting your request quota in the near future, you can submit a request to get an increase with the following form: Functions Limit Increase on Cloudflare Pages


Thanks for your quick reply!

Seems like a very weird decision to have them count against this quota, even though the Function itself is not invoked. I would have expected this kind of limitation to be noted in the documentation.

I’ll keep an eye on the quota for now and request an increase when needed.

As for the Wrangler PR, I’m not using wrangler to deploy my website. But I assume that at some point they’ll have this functionality for websites that are deployed through git as well?

Yes definitely. This should “just work” with sites that you build with Pages that include Functions, and I imagine there’ll be an advanced mode where you can manually tweak things if needed.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.