CLDSRV-855: Update helpers#6128
CLDSRV-855: Update helpers#6128tmacro wants to merge 8 commits intoimprovement/CLDSRV-869/account_limitingfrom
Conversation
Review by Claude Code |
❌ 105 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
lib/Config.js
Outdated
|
|
||
| // Rate limiting uses the same localCache config defined for S3 to avoid config duplication. | ||
| // If rate limiting is enabled check to make sure it is also configured. | ||
| if (config.rateLimiting?.enabled) { |
There was a problem hiding this comment.
Any reason why we don't do something like this now?
| if (config.rateLimiting?.enabled) { | |
| if (this.rateLimiting.enabled) { |
|
LGTM |
| code: errors.SlowDown.message, | ||
| message: errors.SlowDown.description, | ||
| }), | ||
| }).default({ |
There was a problem hiding this comment.
The serviceUserArn is required but doesn't appear in the global default value, is it wanted?
| const applyRateLimit = config.rateLimiting?.enabled | ||
| && !rateLimitApiActions.includes(request.apiMethod) // Don't limit any rate limit admin actions | ||
| && !request.isInternalServiceRequest; // Don't limit any calls from internal services |
There was a problem hiding this comment.
This seems to be done by requestNeedsRateCheck now, but extractAccountRateLimitConfig doesn't call this function, is it expected?
|
|
||
| function buildRateChecksFromConfig(resourceClass, resourceId, limitConfig) { | ||
| const checks = []; | ||
| if (limitConfig?.RequestsPerSecond?.Limit !== undefined && limitConfig.RequestsPerSecond?.Limit > 0) { |
There was a problem hiding this comment.
| if (limitConfig?.RequestsPerSecond?.Limit !== undefined && limitConfig.RequestsPerSecond?.Limit > 0) { | |
| if (limitConfig?.RequestsPerSecond?.Limit > 0) { |
| @@ -1860,23 +1860,15 @@ class Config extends EventEmitter { | |||
| this.enableVeeamRoute = config.enableVeeamRoute; | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
parseRateLimitConfig is now called unconditionally, but serviceUserArn is Joi.string().required() in the schema. If a user has { rateLimiting: { enabled: false } } without serviceUserArn, this will now throw. Previously it worked because parseRateLimitConfig was only called when enabled: true.
Fix: in config.js line 178, make serviceUserArn conditionally required:serviceUserArn: Joi.string().when('enabled', { is: true, then: Joi.required() })
— Claude Code
| log.debug('Rate limit cleanup completed', { expiredConfigs, expiredBucketOwners }); | ||
| } | ||
|
|
||
| cleanupTimer = setTimeout(() => cleanupJob(log), rateLimitCleanupInterval); |
There was a problem hiding this comment.
cleanupJob recursively calls itself without passing options, so skipUnref is lost after the first run. In production this is harmless (options is always empty), but in tests with skipUnref: true the second and subsequent timeouts will call unref() unexpectedly.
Pass options through: setTimeout(() => cleanupJob(log, options), rateLimitCleanupInterval)
— Claude Code
Review by Claude Code |
No description provided.