Rate limiting beta - blocks Worker from running

I have Bindings defined in both my wrangler.toml and in the CF Dashboard.

I added a/the new Rate Limiting Binding in my Worker and deployed it.

I added the Rate Limiter at the start of each endpoint.

But I am getting an error: can't read .limit of undefined

So my Binding is undefined… is there a way I can make this work because the Rate Limiting Binding is not available in the CF Dashboard.


What version of Wrangler are you using? What is an example piece of code that reproduces the issue?

Yeah sorry for leaving that out.

I have nothing related to rate limiting in my Cloudflare Dashboard. There is not option to do so.

In my wrangler.toml I have defined this at the top. I think this means it will apply to all my environments. I have three envdev - staging - production

type = "ratelimit"
namespace_id = "8564"
simple = { limit = 100, period = 60 }

Then in each individual handler of my gets this code. This is copied from the docs exactly. The pathname keeps only that handler locked down by the rate limiter.

I have this code as the first thing in each handler function after destructuring the request.

	const { success } = await env.TRAINING_LOG_WORKER_RATE_LIMITER.limit({ key: pathname });

	if (!success) {
		const response = new Response(`429 Failure: Rate Limit Exceeded For ${pathname}`, { status: 429 });
		return response;

The pathname is coming from the request. new URL(req.url).pathname

Finally, in my env TS definition I have this:

export type Env = {

I want the same variable to apply across Worker environments. Maybe this is my issue?

Should I define variable three times, one for each environment?

This my be really stupid but I as I write this, I’m under the impression that [[unsafe.bindings]] is something you use for beta features…

Should I replace that with [[env.staging.????]]?

Thanks for your help!

UGH… stupid…

If you have environments the binding in the wrangler.toml file needs to go under each environment and then it works perfectly.