Skip to content

Commit ad08c03

Browse files
committed
fix(sdk): inline named limits share the factory's name validation
1 parent ede0e05 commit ad08c03

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

packages/trigger-sdk/src/v3/shared.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ function normalizeTaskConcurrency(
180180
"name" in item &&
181181
typeof item.name === "string"
182182
) {
183+
validateConcurrencyLimitName(item.name);
183184
resourceCatalog.registerConcurrencyLimitMetadata(item);
184185
limits.push(item.name);
185186
} else if (item && typeof item === "object") {
@@ -257,12 +258,16 @@ export function queue(options: QueueOptions): Queue {
257258
* });
258259
* ```
259260
*/
260-
export function concurrencyLimit(options: ConcurrencyLimitOptions): ConcurrencyLimit {
261-
if (options.name.length === 0 || options.name.length > 122 || options.name.includes("/")) {
261+
function validateConcurrencyLimitName(name: string): void {
262+
if (name.length === 0 || name.length > 122 || name.includes("/")) {
262263
throw new Error(
263-
`Concurrency limit "${options.name}": names are 1-122 characters and may not contain "/".`
264+
`Concurrency limit "${name}": names are 1-122 characters and may not contain "/".`
264265
);
265266
}
267+
}
268+
269+
export function concurrencyLimit(options: ConcurrencyLimitOptions): ConcurrencyLimit {
270+
validateConcurrencyLimitName(options.name);
266271

267272
resourceCatalog.registerConcurrencyLimitMetadata(options);
268273

0 commit comments

Comments
 (0)