René's URL Explorer Experiment


Title: bug: batchTrigger returns stale failed runs instead of re-triggering when idempotency key points to a dead run · Issue #4819 · triggerdotdev/trigger.dev · GitHub

Open Graph Title: bug: batchTrigger returns stale failed runs instead of re-triggering when idempotency key points to a dead run · Issue #4819 · triggerdotdev/trigger.dev

X Title: bug: batchTrigger returns stale failed runs instead of re-triggering when idempotency key points to a dead run · Issue #4819 · triggerdotdev/trigger.dev

Description: Bug Description batchTrigger and single trigger behave differently when an idempotency key points to a run that already failed. With single trigger, if a previous run with the same idempotency key ended up in a terminal failure state (CR...

Open Graph Description: Bug Description batchTrigger and single trigger behave differently when an idempotency key points to a run that already failed. With single trigger, if a previous run with the same idempotency key ...

X Description: Bug Description batchTrigger and single trigger behave differently when an idempotency key points to a run that already failed. With single trigger, if a previous run with the same idempotency key ...

Opengraph URL: https://github.com/triggerdotdev/trigger.dev/issues/4819

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"bug: batchTrigger returns stale failed runs instead of re-triggering when idempotency key points to a dead run","articleBody":"## Bug Description\n\n`batchTrigger` and single `trigger` behave differently when an idempotency key points to a run that already failed.\n\nWith single `trigger`, if a previous run with the same idempotency key ended up in a terminal failure state (`CRASHED`, `SYSTEM_FAILURE`, `TIMED_OUT`, `EXPIRED`, `COMPLETED_WITH_ERRORS`, `INTERRUPTED`), it correctly clears the key and creates a fresh run. This works because `IdempotencyKeyConcern.handleExistingRun` calls `shouldIdempotencyKeyBeCleared(status)` before deciding whether to return a cached result.\n\nWith `batchTrigger`, that same check is missing. The batch path in `BatchTriggerV3Service.#prepareRunData` only checks time-based expiration (`idempotencyKeyExpiresAt \u003c now`), so a failed run gets returned as `isCached: true` — silently handing back a dead run that will never produce output.\n\n## Steps to Reproduce\n\n```typescript\n// 1. A task that always fails\nexport const failingTask = task({\n  id: \"failing-task\",\n  run: async () => { throw new Error(\"boom\"); },\n});\n\n// 2. Batch trigger with idempotency key\nawait tasks.batchTrigger(\"failing-task\", [\n  { payload: {}, options: { idempotencyKey: \"key-1\" } },\n]);\n// Wait for the run to reach CRASHED / COMPLETED_WITH_ERRORS...\n\n// 3. Trigger again with the same key\nawait tasks.batchTrigger(\"failing-task\", [\n  { payload: {}, options: { idempotencyKey: \"key-1\" } },\n]);\n// Expected: isCached: false (fresh run created)\n// Actual:   isCached: true  (dead run returned)\n```\n\nCompare with single trigger — this already works correctly:\n```typescript\nawait tasks.trigger(\"failing-task\", {}, { idempotencyKey: \"key-2\" });\n// Wait for failure...\nawait tasks.trigger(\"failing-task\", {}, { idempotencyKey: \"key-2\" });\n// Correctly returns isCached: false and creates a new run\n```\n\n## Root Cause\n\nThe SQL query in `PostgresRunStore.findRunsByIdempotencyKeys` never selects the `status` column, and the `IdempotencyKeyRunMatch` type doesn't include it. So `#prepareRunData` has no way to check whether a matched run is in a clearable failure state — it can only check time-based expiration.\n\nThe single-trigger path works because `IdempotencyKeyConcern.handleExistingRun` fetches the full run record and calls `shouldIdempotencyKeyBeCleared(status)` at [idempotencyKeys.server.ts:463](https://github.com/triggerdotdev/trigger.dev/blob/main/apps/webapp/app/runEngine/concerns/idempotencyKeys.server.ts#L463). The batch path at [batchTriggerV3.server.ts:452-469](https://github.com/triggerdotdev/trigger.dev/blob/main/apps/webapp/app/v3/services/batchTriggerV3.server.ts#L452-L469) skips this entirely.\n\n| Check | Single trigger | Batch trigger |\n|---|---|---|\n| Time-based expiry | ✅ `idempotencyKeyExpiresAt \u003c now` | ✅ `idempotencyKeyExpiresAt \u003c now` |\n| Failure status check | ✅ `shouldIdempotencyKeyBeCleared(status)` | ❌ **Missing** |\n\n## Affected Statuses\n\nThese statuses should clear the idempotency key and re-trigger (works for single trigger, broken for batch):\n- `CRASHED`\n- `SYSTEM_FAILURE`\n- `TIMED_OUT`\n- `EXPIRED`\n- `COMPLETED_WITH_ERRORS`\n- `INTERRUPTED`\n\n## Suggested Fix\n\nI already wrote and tested a patch for this. My PR #4818 was auto-closed since I'm not a vouched contributor, but the fix is ready on my fork if you'd like to pull it in or use it as reference:\n\n**Branch:** [`Jaimin2687:fix/batch-trigger-idempotency-key-status-check`](https://github.com/Jaimin2687/trigger.dev/tree/fix/batch-trigger-idempotency-key-status-check)\n\nThe fix is three small changes:\n\n1. **`internal-packages/run-store/src/types.ts`** — Add `status: string` to `IdempotencyKeyRunMatch`\n2. **`internal-packages/run-store/src/PostgresRunStore.ts`** — Add `\"status\"` to the raw SQL SELECT in `findRunsByIdempotencyKeys`\n3. **`apps/webapp/app/v3/services/batchTriggerV3.server.ts`** — Import `shouldIdempotencyKeyBeCleared` and add the guard after the expiry check in `#prepareRunData`, mirroring the single-trigger path\n\nThe branch also includes 21 unit tests and 2 integration tests (testcontainers) covering all `TaskRunStatus` values. Everything passes typecheck, build, format, and lint.\n\n## Environment\n\n- trigger.dev `main` branch (as of Aug 28, 2025)\n- Affects all environments (dev, staging, production)\n- Backend only, no UI impact","author":{"url":"https://github.com/Jaimin2687","@type":"Person","name":"Jaimin2687"},"datePublished":"2026-08-28T13:53:16Z","url":"https://github.com/triggerdotdev/trigger.dev/issues/4819"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:492bbd68-b6db-6298-d7f7-5cf17bf2789f
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA256:D23AD:304ED3E:4172007:6AFAD85A
html-safe-noncef336fef3c4ed0e7f646f4cab23a83efcf05a74a1a7e5da63c57837eaf7a0fe16
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMjU2OkQyM0FEOjMwNEVEM0U6NDE3MjAwNzo2QUZBRDg1QSIsInZpc2l0b3JfaWQiOiIzMjE2NzcwMTY2Nzc5NzMwMDEwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac3bef014dd3c444819f79099c58ff3f55794c584485b312f7d6ee071cf7b85adb
hovercard-subject-tagissue:5278895159
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/triggerdotdev/trigger.dev/4819/issue_layout
twitter:imagehttps://opengraph.githubassets.com/cb4db5a021a503312d59c3551ff5666ca3857e5f2b0e099bda32769f297de76f/triggerdotdev/trigger.dev/issues/4819
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/cb4db5a021a503312d59c3551ff5666ca3857e5f2b0e099bda32769f297de76f/triggerdotdev/trigger.dev/issues/4819
og:image:altBug Description batchTrigger and single trigger behave differently when an idempotency key points to a run that already failed. With single trigger, if a previous run with the same idempotency key ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameJaimin2687
hostnamegithub.com
expected-hostnamegithub.com
None02f4c00e74911c7cd779fc232c3130cee49eb39fd0ed4bfe3eea3b82c7c18084
turbo-cache-controlno-preview
go-importgithub.com/triggerdotdev/trigger.dev git https://github.com/triggerdotdev/trigger.dev.git
octolytics-dimension-user_id95297378
octolytics-dimension-user_logintriggerdotdev
octolytics-dimension-repository_id572570113
octolytics-dimension-repository_nwotriggerdotdev/trigger.dev
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id572570113
octolytics-dimension-repository_network_root_nwotriggerdotdev/trigger.dev
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release33c41e9d150e44415272934d676dc63c57d89c3b
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/triggerdotdev/trigger.dev/issues/4819#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fissues%2F4819
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fissues%2F4819
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=triggerdotdev%2Ftrigger.dev
Reloadhttps://github.com/triggerdotdev/trigger.dev/issues/4819
Reloadhttps://github.com/triggerdotdev/trigger.dev/issues/4819
Reloadhttps://github.com/triggerdotdev/trigger.dev/issues/4819
triggerdotdevhttps://github.com/triggerdotdev
trigger.devhttps://github.com/triggerdotdev/trigger.dev
Codehttps://github.com/triggerdotdev/trigger.dev
Issues203 (203)https://github.com/triggerdotdev/trigger.dev/issues
Pull requests65 (65)https://github.com/triggerdotdev/trigger.dev/pulls
Discussionshttps://github.com/triggerdotdev/trigger.dev/discussions
Actionshttps://github.com/triggerdotdev/trigger.dev/actions
Projectshttps://github.com/triggerdotdev/trigger.dev/projects
Security and quality39 (39)https://github.com/triggerdotdev/trigger.dev/security
Insightshttps://github.com/triggerdotdev/trigger.dev/pulse
https://github.com/triggerdotdev/trigger.dev
New issuehttps://github.com/login?return_to=https://github.com/triggerdotdev/trigger.dev/issues/4819
New issuehttps://github.com/login?return_to=https://github.com/triggerdotdev/trigger.dev/issues/4819
bug: batchTrigger returns stale failed runs instead of re-triggering when idempotency key points to a dead runhttps://github.com/triggerdotdev/trigger.dev/issues/4819#top
https://github.com/Jaimin2687
Jaimin2687https://github.com/Jaimin2687
on Aug 28, 2026https://github.com/triggerdotdev/trigger.dev/issues/4819#issue-5278895159
idempotencyKeys.server.ts:463https://github.com/triggerdotdev/trigger.dev/blob/main/apps/webapp/app/runEngine/concerns/idempotencyKeys.server.ts#L463
batchTriggerV3.server.ts:452-469https://github.com/triggerdotdev/trigger.dev/blob/main/apps/webapp/app/v3/services/batchTriggerV3.server.ts#L452-L469
#4818https://github.com/triggerdotdev/trigger.dev/pull/4818
Jaimin2687:fix/batch-trigger-idempotency-key-status-checkhttps://github.com/Jaimin2687/trigger.dev/tree/fix/batch-trigger-idempotency-key-status-check
https://github.com/itzzdev09
itzzdev09https://github.com/itzzdev09
on Aug 28, 2026https://github.com/triggerdotdev/trigger.dev/issues/4819#issuecomment-5458250243
https://github.com/breken-ai
breken-aihttps://github.com/breken-ai
on Sep 9, 2026https://github.com/triggerdotdev/trigger.dev/issues/4819#issuecomment-5602007808
@Jaimin2687https://github.com/Jaimin2687
@itzzdev09https://github.com/itzzdev09
#4912https://github.com/triggerdotdev/trigger.dev/pull/4912
61465https://github.com/61465
on Oct 10, 2026https://github.com/triggerdotdev/trigger.dev/issues/4819#event-32951643337
fix(batchTrigger): clear idempotency key when previous run failed + d…https://github.com/61465/trigger.dev/commit/da93e87ff3f2a582fb29e756b99494d5957f38cc
https://docs.github.com/articles/closing-issues-via-commit-messages
da93e87https://github.com/61465/trigger.dev/commit/da93e87ff3f2a582fb29e756b99494d5957f38cc
Sign up for freehttps://github.com/signup?return_to=https://github.com/triggerdotdev/trigger.dev/issues/4819
Sign in to commenthttps://github.com/login?return_to=https://github.com/triggerdotdev/trigger.dev/issues/4819
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.