User_10_secs_limit

Slow down, you're making too many requests.
Please retry again in 5 seconds.
Error code: user_10_secs_limit.

I created a theme that uses await ajax(/t/${this.args.topic.id}.json); . This gets rate-limited due to excessive requests. How can I avoid this? I noticed the restriction is flagged as a ​user-level limit , not an IP-based limit.

Are you behind a load balancer like cloudflare so that Discourse doesn’t know the user’s actual IP address?

A quick grep and I don’t see user_10_secs_limit in the code except in a spec. I suspect it might be IP related in spite of the error you are seeing.

Here - You can’t grep it :slight_smile:

error_code: "#{error_code_identifier}_10_secs_limit",

Coming from discourse/lib/request_tracker/rate_limiters/user.rb at main · discourse/discourse · GitHub

@truman is your theme component doing this for many topics? What exactly are you trying to accomplish? You should either see if you can combine the calls, for instance by tagging the topics and then retrieving them by tag in a single call, and/or you should figure out a cache mechanism.

2 Likes

Aha! I figured I was overlooking something simple. . .

1 Like

I want to fetch the reactions for each topic so that I can display them on the homepage. like:
image

You need serialise this in a plugin to avoid all these queries so all the data you need is brought down in one go.

You should not have to fire off a query for every topic in your topic list. That’s never going to scale.

For an example of where this is done take a look at Topic List Previews.

4 Likes

Get the all-the-plugins repo and look for add_to_serializer

3 Likes