User_10_secs_limit

סיכום מבוסס בינה מלאכותית

The discussion centers around a theme created by truman that is triggering the user_10_secs_limit error due to excessive AJAX requests when fetching topic data. The error message indicates a user-level rate limit. pfaffman initially suspected an IP-related issue, but RGJ pointed to the relevant code defining the error https://github.com/discourse/discourse/blob/main/lib/middleware/request_tracker.rb#L492.

truman explains that the goal is to display topic reactions on the homepage, as shown in the provided image. Several users suggest alternatives to avoid numerous requests: merefield recommends serializing the process within a plugin to retrieve all necessary data in a single query, referencing the “Topic List Previews” plugin https://github.com/merefield/discourse-topic-previews-sidecar/blob/master/lib/topic_previews/topic_list_item_serializer_extension.rb. pfaffman advises checking the ‘all-the-plugins’ repo for examples of add_to_serializer functionality.

האט את הקצב, אתה שולח יותר מדי בקשות.
אנא נסה שוב בעוד 5 שניות.
קוד שגיאה: user_10_secs_limit.

יצרתי ערכת נושא (theme) שמשתמשת ב-await ajax(/t/${this.args.topic.id}.json);. זה מגיע להגבלת קצב (rate-limited) עקב בקשות מרובות. כיצד אוכל להימנע מכך? שמתי לב שההגבלה מסומנת כ​הגבלה ברמת משתמש , לא הגבלה מבוססת IP.

האם אתה מאחורי מאזן עומסים כמו Cloudflare כך ש-Discourse לא ידע את כתובת ה-IP האמיתית של המשתמש?
חיפוש מהיר באמצעות grep ולא מצאתי user_10_secs_limit בקוד מלבד ב-spec. אני חושד שזה קשור ל-IP למרות השגיאה שאתה רואה.

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.

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

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

אתה צריך לבצע סריאליזציה של זה בתוסף כדי להימנע מכל השאילתות האלה.

קבל את מאגר all-the-plugins וחפש את add_to_serializer