Title: bug: task.batchTriggerAndWait(array) silently drops per-item debounce options · Issue #3304 · triggerdotdev/trigger.dev · GitHub
Open Graph Title: bug: task.batchTriggerAndWait(array) silently drops per-item debounce options · Issue #3304 · triggerdotdev/trigger.dev
X Title: bug: task.batchTriggerAndWait(array) silently drops per-item debounce options · Issue #3304 · triggerdotdev/trigger.dev
Description: Provide environment information System: OS: Linux 6.17 Ubuntu 24.04.4 LTS 24.04.4 LTS (Noble Numbat) CPU: (6) arm64 unknown Memory: 14.04 GB / 31.27 GB Shell: 5.2.21 - /bin/bash Binaries: Node: 24.13.1 - /home/main/n/bin/node npm: 11.8.0...
Open Graph Description: Provide environment information System: OS: Linux 6.17 Ubuntu 24.04.4 LTS 24.04.4 LTS (Noble Numbat) CPU: (6) arm64 unknown Memory: 14.04 GB / 31.27 GB Shell: 5.2.21 - /bin/bash Binaries: Node: 24....
X Description: Provide environment information System: OS: Linux 6.17 Ubuntu 24.04.4 LTS 24.04.4 LTS (Noble Numbat) CPU: (6) arm64 unknown Memory: 14.04 GB / 31.27 GB Shell: 5.2.21 - /bin/bash Binaries: Node: 24....
Opengraph URL: https://github.com/triggerdotdev/trigger.dev/issues/3304
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"bug: task.batchTriggerAndWait(array) silently drops per-item debounce options","articleBody":"### Provide environment information\n\n System: \n OS: Linux 6.17 Ubuntu 24.04.4 LTS 24.04.4 LTS (Noble Numbat) \n CPU: (6) arm64 unknown \n Memory: 14.04 GB / 31.27 GB \n Shell: 5.2.21 - /bin/bash \n Binaries: \n Node: 24.13.1 - /home/main/n/bin/node \n npm: 11.8.0 - /home/main/n/bin/npm \n pnpm: 10.28.2 - /home/main/.local/share/pnpm/pnpm \n\n SDK version: @trigger.dev/sdk@4.4.3 \n\n### Describe the bug\n\nWhen calling `task.batchTriggerAndWait(items)` with an array of items that include `debounce` in their `options`, the debounce is silently ignored. Every item creates a separate run instead of coalescing by debounce key. The TypeScript types accept `debounce` in per-item options, so there's no compile-time warning.\n\nThe same items passed via an async iterable (`task.batchTriggerAndWait(asyncGenerator())`) correctly apply debounce.\n\n**Root cause:** In `packages/trigger-sdk/src/v3/shared.ts`, the `batchTriggerAndWait_internal` function's **array branch** (around line 2484) constructs per-item options by explicitly listing fields, and `debounce` is missing from the list:\n\n```ts\nlockToVersion, queue, concurrencyKey, test, payloadType, delay, ttl,\ntags, maxAttempts, metadata, maxDuration, idempotencyKey,\nidempotencyKeyTTL, idempotencyKeyOptions, machine, priority, region\n```\n\nThe **streaming transforms** (e.g., `transformSingleTaskBatchItemsStreamForWait`) correctly include `debounce: item.options?.debounce`.\n\n### Reproduction repo\n\nhttps://github.com/triggerdotdev/trigger.dev/blob/2ba77d8/packages/trigger-sdk/src/v3/shared.ts#L2484-L2510\n\n### To reproduce\n\n\n```ts\nimport { task } from \"@trigger.dev/sdk\";\n\nconst myTask = task({\n id: \"my-task\",\n run: async (payload: { id: string }) => {\n await new Promise((r) => setTimeout(r, 5000));\n return { done: true };\n },\n});\n\n// Parent task\nconst parent = task({\n id: \"parent\",\n run: async () => {\n // These should coalesce into 1 run per key, but each creates a separate run\n const results = await myTask.batchTriggerAndWait([\n { payload: { id: \"a\" }, options: { debounce: { key: \"same-key\", delay: \"30s\", mode: \"trailing\" } } },\n { payload: { id: \"b\" }, options: { debounce: { key: \"same-key\", delay: \"30s\", mode: \"trailing\" } } },\n { payload: { id: \"c\" }, options: { debounce: { key: \"same-key\", delay: \"30s\", mode: \"trailing\" } } },\n ]);\n\n // Expected: 1 run (all 3 debounced to same key)\n // Actual: 3 separate runs\n console.log(\"Runs:\", results.runs.length);\n },\n});\n```\n\n**Workaround:** Use an async iterable instead of an array:\n\n```ts\nasync function* items() {\n yield { payload: { id: \"a\" }, options: { debounce: { key: \"same-key\", delay: \"30s\", mode: \"trailing\" } } };\n yield { payload: { id: \"b\" }, options: { debounce: { key: \"same-key\", delay: \"30s\", mode: \"trailing\" } } };\n yield { payload: { id: \"c\" }, options: { debounce: { key: \"same-key\", delay: \"30s\", mode: \"trailing\" } } };\n}\n\nconst results = await myTask.batchTriggerAndWait(items());\n// Correctly produces 1 run\n```\n\n### Additional information\n\nThe fix should be a one-line addition in `batchTriggerAndWait_internal`'s array branch — add `debounce: item.options?.debounce` to the per-item options object, matching what the streaming transforms already do.\n\n**Affected paths:**\n- `task.batchTriggerAndWait(array)` — broken\n- `tasks.batchTriggerAndWait(id, array)` — broken (same internal function)\n\n**Working paths:**\n- `task.batchTriggerAndWait(asyncIterable)` — works\n- `batch.triggerAndWait(items)` (heterogeneous) — works\n- `task.batchTrigger(array)` (fire-and-forget) — works\n","author":{"url":"https://github.com/danielr18","@type":"Person","name":"danielr18"},"datePublished":"2026-03-31T17:07:46Z","url":"https://github.com/triggerdotdev/trigger.dev/issues/3304"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2c3177a7-6c32-ca77-e146-332067dcb4f4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CF50:79AE7:49CA6B5:63772BC:6AFAF4BD |
| html-safe-nonce | e09e5f64846966c30c72082dae106b12ec5c8eb8c38792e977e627e177ba377d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRjUwOjc5QUU3OjQ5Q0E2QjU6NjM3NzJCQzo2QUZBRjRCRCIsInZpc2l0b3JfaWQiOiIxMTE2OTE3ODczNTk2MTAxODIxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | da0de4d74b73eee8842a036322858e61e7bb7c13859ffb49cb4f82fa59df8041 |
| hovercard-subject-tag | issue:4180874651 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/triggerdotdev/trigger.dev/3304/issue_layout |
| twitter:image | https://opengraph.githubassets.com/96c461abc8a5d7827a8f16f67f4ac20a1d4a9e3654cd9599e11c0d01504bc0af/triggerdotdev/trigger.dev/issues/3304 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/96c461abc8a5d7827a8f16f67f4ac20a1d4a9e3654cd9599e11c0d01504bc0af/triggerdotdev/trigger.dev/issues/3304 |
| og:image:alt | Provide environment information System: OS: Linux 6.17 Ubuntu 24.04.4 LTS 24.04.4 LTS (Noble Numbat) CPU: (6) arm64 unknown Memory: 14.04 GB / 31.27 GB Shell: 5.2.21 - /bin/bash Binaries: Node: 24.... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | danielr18 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0178036d8230524a18422872393ab7e708443ae4c2047f758560a2db870c1913 |
| turbo-cache-control | no-preview |
| go-import | github.com/triggerdotdev/trigger.dev git https://github.com/triggerdotdev/trigger.dev.git |
| octolytics-dimension-user_id | 95297378 |
| octolytics-dimension-user_login | triggerdotdev |
| octolytics-dimension-repository_id | 572570113 |
| octolytics-dimension-repository_nwo | triggerdotdev/trigger.dev |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 572570113 |
| octolytics-dimension-repository_network_root_nwo | triggerdotdev/trigger.dev |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | a85e96a83bed7871993e6b1ffda24105928eee17 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width