diff --git a/internal/extsvc/types.go b/internal/extsvc/types.go index a52f65ac292..3fa21c26738 100644 --- a/internal/extsvc/types.go +++ b/internal/extsvc/types.go @@ -436,14 +436,20 @@ func GetLimitFromConfig(kind string, config interface{}) (rate.Limit, error) { limit = limitOrInf(c.RateLimit.Enabled, c.RateLimit.RequestsPerHour) } case *schema.NpmPackagesConnection: - // 3000 per hour is the same default we use in our schema - limit = rate.Limit(3000.0 / 3600.0) + // Unlike the GitHub or GitLab APIs, the public npm registry (i.e. https://registry.npmjs.org) + // doesn't document an enforced req/s rate limit AND we do a lot more individual + // requests in comparison since they don't offer enough batch APIs. For private registries, + // site-admins can manually configure their desired rate limits if needed. + limit = rate.Inf if c != nil && c.RateLimit != nil { limit = limitOrInf(c.RateLimit.Enabled, c.RateLimit.RequestsPerHour) } case *schema.GoModulesConnection: - // 3000 per hour is the same default we use in our schema - limit = rate.Limit(3000.0 / 3600.0) + // Unlike the GitHub or GitLab APIs, the public npm registry (i.e. https://proxy.golang.org) + // doesn't document an enforced req/s rate limit AND we do a lot more individual + // requests in comparison since they don't offer enough batch APIs. For private proxies, + // site-admins can manually configure their desired rate limits if needed. + limit = rate.Inf if c != nil && c.RateLimit != nil { limit = limitOrInf(c.RateLimit.Enabled, c.RateLimit.RequestsPerHour) } diff --git a/internal/extsvc/types_test.go b/internal/extsvc/types_test.go index 141f96a992d..6783dbcfcca 100644 --- a/internal/extsvc/types_test.go +++ b/internal/extsvc/types_test.go @@ -112,7 +112,7 @@ func TestExtractRateLimitConfig(t *testing.T) { name: "NPM default", config: `{"registry": "https://registry.npmjs.org"}`, kind: KindNpmPackages, - want: 3000.0 / 3600.0, + want: rate.Inf, }, { name: "NPM non-default", @@ -124,7 +124,7 @@ func TestExtractRateLimitConfig(t *testing.T) { name: "Go mod default", config: `{"urls": ["https://example.com"]}`, kind: KindGoModules, - want: 3000.0 / 3600.0, + want: rate.Inf, }, { name: "Go mod non-default", diff --git a/schema/go-modules.schema.json b/schema/go-modules.schema.json index 0cf10538e22..59adab9c81f 100644 --- a/schema/go-modules.schema.json +++ b/schema/go-modules.schema.json @@ -31,13 +31,13 @@ "requestsPerHour": { "description": "Requests per hour permitted. This is an average, calculated per second. Internally, the burst limit is set to 100, which implies that for a requests per hour limit as low as 1, users will continue to be able to send a maximum of 100 requests immediately, provided that the complexity cost of each request is 1.", "type": "number", - "default": 3000, + "default": 57600, "minimum": 0 } }, "default": { "enabled": true, - "requestsPerHour": 3000 + "requestsPerHour": 57600 } }, "dependencies": { diff --git a/schema/npm-packages.schema.json b/schema/npm-packages.schema.json index bc7653a016b..37ee9914e72 100644 --- a/schema/npm-packages.schema.json +++ b/schema/npm-packages.schema.json @@ -34,13 +34,13 @@ "requestsPerHour": { "description": "Requests per hour permitted. This is an average, calculated per second. Internally, the burst limit is set to 100, which implies that for a requests per hour limit as low as 1, users will continue to be able to send a maximum of 100 requests immediately, provided that the complexity cost of each request is 1.", "type": "number", - "default": 3000, + "default": 57600, "minimum": 0 } }, "default": { "enabled": true, - "requestsPerHour": 3000 + "requestsPerHour": 57600 } }, "dependencies": {