We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 23d8001 commit 111a095Copy full SHA for 111a095
packages/service-utils/src/core/rateLimit/index.ts
@@ -71,9 +71,15 @@ export async function rateLimit(args: {
71
limitPerSecond * sampleRate * RATE_LIMIT_WINDOW_SECONDS;
72
73
if (requestCount > limitPerWindow) {
74
- // Report rate limit hits.
75
- if (project?.id) {
76
- await updateRateLimitedAt(project.id, serviceConfig);
+ /**
+ * Report rate limit hits.
+ * Only track rate limit when its hit for the first time.
77
+ * Not waiting for tracking to complete as user doesn't need to wait.
78
+ */
79
+ if (requestCount === 1 && project?.id) {
80
+ updateRateLimitedAt(project.id, serviceConfig).catch(() => {
81
+ // no-op
82
+ });
83
}
84
85
// Reject requests when they've exceeded 2x the rate limit.
0 commit comments