Skip to content

Commit 9807331

Browse files
committed
fix(react-hooks): reject more than two named limits instead of truncating
Matches the SDK's trigger validation, and the shared changeset now versions react-hooks alongside sdk and core.
1 parent 13c5bc5 commit 9807331

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎.changeset/task-concurrency.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
"@trigger.dev/sdk": patch
33
"@trigger.dev/core": patch
4+
"@trigger.dev/react-hooks": patch
45
---
56

67
Control a task's concurrency with the new `concurrency` option, and share limits across tasks with named concurrency limits. An inline shape caps the task itself; `concurrencyLimit()` declares a limit any task can hold (up to two named limits per task), and a trigger call can switch a run's named limits with its own `concurrency` option.

‎packages/react-hooks/src/hooks/useTaskTrigger.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,15 @@ export function useTaskTrigger<TTask extends AnyTask>(
7575

7676
const queueName = options?.queue;
7777
const concurrency = options?.concurrency
78-
? (Array.isArray(options.concurrency) ? options.concurrency : [options.concurrency]).slice(
79-
0,
80-
2
81-
)
78+
? Array.isArray(options.concurrency)
79+
? options.concurrency
80+
: [options.concurrency]
8281
: undefined;
8382

83+
if (concurrency && concurrency.length > 2) {
84+
throw new Error("The concurrency option accepts at most two named limits.");
85+
}
86+
8487
const handle = await apiClient.triggerTask(id, {
8588
payload: payloadPacket.data,
8689
options: {

0 commit comments

Comments
 (0)