René's URL Explorer Experiment


Title: fix: batch trigger returns stale failed runs when idempotency key points to a dead run by Jaimin2687 · Pull Request #4818 · triggerdotdev/trigger.dev · GitHub

Open Graph Title: fix: batch trigger returns stale failed runs when idempotency key points to a dead run by Jaimin2687 · Pull Request #4818 · triggerdotdev/trigger.dev

X Title: fix: batch trigger returns stale failed runs when idempotency key points to a dead run by Jaimin2687 · Pull Request #4818 · triggerdotdev/trigger.dev

Description: What happened I noticed that 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 (CRASHED, SYSTEM_FAILURE, TIMED_OUT, EXPIRED, COMPLETED_WITH_ERRORS, INTERRUPTED), the SDK 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. With batchTrigger, that check was missing entirely. The batch path in BatchTriggerV3Service.#prepareRunData only checked time-based expiration (idempotencyKeyExpiresAt < now), so a failed run would get returned as isCached: true — silently handing back a dead run that will never produce output. The root cause turned out to be pretty simple: the SQL query backing findRunsByIdempotencyKeys never selected the status column, and the IdempotencyKeyRunMatch type didn't include it. So even if someone wanted to add the check, the data wasn't there. What this PR does Three small changes: Added status to the query and its return type — IdempotencyKeyRunMatch in run-store/src/types.ts now includes status: string, and the raw SQL in PostgresRunStore.findRunsByIdempotencyKeys selects it. Added the missing status check in the batch path — After the existing expiry check in #prepareRunData, there's now a shouldIdempotencyKeyBeCleared(cachedRun.status) guard that mirrors what the single-trigger path already does. If the cached run is in a failure state, we add it to expiredRunIds (so the key gets cleared) and mint a new run ID. Added the import — shouldIdempotencyKeyBeCleared was already exported from taskStatus.ts, just not imported in the batch service. ✅ Checklist I have followed every step in the contributing guide The PR title follows the convention I ran and tested the code works Testing Unit tests — Added 21 tests in batchTriggerIdempotencyStatusCheck.test.ts that cover every TaskRunStatus value against shouldIdempotencyKeyBeCleared: All 6 failure statuses correctly return true (key should be cleared, run re-triggered) All 11 non-failure statuses correctly return false (run stays cached) Explicit edge cases for COMPLETED_SUCCESSFULLY (valid cache), CANCELED (user-intentional), RETRYING_AFTER_FAILURE (still in progress), and EXPIRED Integration tests — Extended the existing PostgresRunStore.findRunsByIdempotencyKeys.test.ts with testcontainers: Added status assertions to the existing test (catches future regressions if someone removes the column) New test: creates runs in all 6 failure statuses and verifies the query returns the correct status for each New test: verifies COMPLETED_SUCCESSFULLY status is returned correctly Build verification: pnpm run typecheck --filter webapp ✅ pnpm run build --filter @internal/run-store ✅ pnpm run format ✅ pnpm run lint:fix ✅ (0 warnings, 0 errors) How to reproduce the bug manually: // 1. A task that always fails export const failingTask = task({ id: "failing-task", run: async () => { throw new Error("boom"); }, }); // 2. Batch trigger with idempotency key await tasks.batchTrigger("failing-task", [ { payload: {}, options: { idempotencyKey: "key-1" } }, ]); // Wait for the run to fail... // 3. Trigger again — before this fix, you get the dead run back await tasks.batchTrigger("failing-task", [ { payload: {}, options: { idempotencyKey: "key-1" } }, ]); // BEFORE: isCached: true (dead run returned) // AFTER: isCached: false (fresh run created) Changelog Batch triggers with idempotency keys now correctly re-trigger when a previous run failed, matching the existing single-trigger behavior. Previously, calling batchTrigger with an idempotency key that pointed to a crashed or failed run would silently return the dead run instead of starting a new one. Screenshots N/A — backend-only change, no UI impact. 💯

Open Graph Description: What happened I noticed that 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 ide...

X Description: What happened I noticed that 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 ide...

Opengraph URL: https://github.com/triggerdotdev/trigger.dev/pull/4818

X: @github

direct link

Domain: github.com

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/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:e120793c-24bd-4a86-f1d5-105f37367852
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA2AC:79AE7:44E7913:5C832E0:6AFADCDE
html-safe-nonced4ba584be3e002e1ced914d90b9971b4edcfd31ada4bc321a29ef8c4bb951a67
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMkFDOjc5QUU3OjQ0RTc5MTM6NUM4MzJFMDo2QUZBRENERSIsInZpc2l0b3JfaWQiOiI1OTg0Njk4MDgxNjIwOTc0ODE0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac347891fe3dc32e025190b6c22357ae2b80f9fe7c702f7fb4c4359f607f8c320f
hovercard-subject-tagpull_request:4385231068
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/triggerdotdev/trigger.dev/pull/4818/files
twitter:imagehttps://avatars.githubusercontent.com/u/132206640?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/132206640?s=400&v=4
og:image:altWhat happened I noticed that 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 ide...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None9d9bd51a568909a83d1abb9d6f74d68f0c87ca85fe3a56d3f5d70d8b89add9f2
turbo-cache-controlno-preview
diff-viewunified
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 full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release4a7ae932999cc6d511008dbf980ff9efad2a31f7
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/triggerdotdev/trigger.dev/pull/4818/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fpull%2F4818%2Ffiles
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%2Fpull%2F4818%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=triggerdotdev%2Ftrigger.dev
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/4818/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/4818/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/4818/files
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 requests66 (66)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
Sign up for GitHub https://github.com/signup?return_to=%2Ftriggerdotdev%2Ftrigger.dev%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Ftriggerdotdev%2Ftrigger.dev%2Fissues%2Fnew%2Fchoose
Jaimin2687https://github.com/Jaimin2687
triggerdotdev:mainhttps://github.com/triggerdotdev/trigger.dev/tree/main
Jaimin2687:fix/batch-trigger-idempotency-key-status-checkhttps://github.com/Jaimin2687/trigger.dev/tree/fix/batch-trigger-idempotency-key-status-check
Conversation 5 https://github.com/triggerdotdev/trigger.dev/pull/4818
Commits 1 https://github.com/triggerdotdev/trigger.dev/pull/4818/commits
Checks 2 https://github.com/triggerdotdev/trigger.dev/pull/4818/checks
Files changed https://github.com/triggerdotdev/trigger.dev/pull/4818/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4818/files
fix: batch trigger returns stale failed runs when idempotency key points to a dead run https://github.com/triggerdotdev/trigger.dev/pull/4818/files#top
Show all changes 1 commit https://github.com/triggerdotdev/trigger.dev/pull/4818/files
54a6df6 fix: batch trigger skips idempotency key status check for failed runs Jaimin2687 Aug 28, 2026 https://github.com/triggerdotdev/trigger.dev/pull/4818/commits/54a6df6e98a65efecc4399ecc68aa58ff1ceedd4
Clear filters https://github.com/triggerdotdev/trigger.dev/pull/4818/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4818/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4818/files
batchTriggerV3.server.ts https://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-55867b934007572d29b5479a4721efceb9743d246bfaf3a4401371bab53beebd
batchTriggerIdempotencyStatusCheck.test.ts https://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-b0c9ee16d52c596eb67fb86c82a19792911e332c94eb6fc5afced996b0b686ac
PostgresRunStore.findRunsByIdempotencyKeys.test.ts https://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-99988478d8eff178f7816d114388452cf309398e58ad837efe0379d266179b8f
PostgresRunStore.ts https://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-9c06c7000b359bcaa2f0b637af253ebfe2e2d9cf43568e42592b0e26f6910258
types.ts https://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-3b72267802fbd082b93adb08e3e014e75f40eb755c8a4f14bd7a76148f49ffe8
apps/webapp/app/v3/services/batchTriggerV3.server.tshttps://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-55867b934007572d29b5479a4721efceb9743d246bfaf3a4401371bab53beebd
View file https://github.com/Jaimin2687/trigger.dev/blob/54a6df6e98a65efecc4399ecc68aa58ff1ceedd4/apps/webapp/app/v3/services/batchTriggerV3.server.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4818/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-55867b934007572d29b5479a4721efceb9743d246bfaf3a4401371bab53beebd
https://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-55867b934007572d29b5479a4721efceb9743d246bfaf3a4401371bab53beebd
https://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-55867b934007572d29b5479a4721efceb9743d246bfaf3a4401371bab53beebd
https://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-55867b934007572d29b5479a4721efceb9743d246bfaf3a4401371bab53beebd
devin-ai-integrationhttps://github.com/apps/devin-ai-integration
Aug 28, 2026https://github.com/triggerdotdev/trigger.dev/pull/4818/files#r3881117892
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
https://app.devin.ai/review/triggerdotdev/trigger.dev/pull/4818
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4818/files
https://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-55867b934007572d29b5479a4721efceb9743d246bfaf3a4401371bab53beebd
apps/webapp/test/batchTriggerIdempotencyStatusCheck.test.tshttps://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-b0c9ee16d52c596eb67fb86c82a19792911e332c94eb6fc5afced996b0b686ac
View file https://github.com/Jaimin2687/trigger.dev/blob/54a6df6e98a65efecc4399ecc68aa58ff1ceedd4/apps/webapp/test/batchTriggerIdempotencyStatusCheck.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4818/{{ revealButtonHref }}
internal-packages/run-store/src/PostgresRunStore.findRunsByIdempotencyKeys.test.tshttps://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-99988478d8eff178f7816d114388452cf309398e58ad837efe0379d266179b8f
View file https://github.com/Jaimin2687/trigger.dev/blob/54a6df6e98a65efecc4399ecc68aa58ff1ceedd4/internal-packages/run-store/src/PostgresRunStore.findRunsByIdempotencyKeys.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4818/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-99988478d8eff178f7816d114388452cf309398e58ad837efe0379d266179b8f
https://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-99988478d8eff178f7816d114388452cf309398e58ad837efe0379d266179b8f
https://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-99988478d8eff178f7816d114388452cf309398e58ad837efe0379d266179b8f
https://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-99988478d8eff178f7816d114388452cf309398e58ad837efe0379d266179b8f
https://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-99988478d8eff178f7816d114388452cf309398e58ad837efe0379d266179b8f
https://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-99988478d8eff178f7816d114388452cf309398e58ad837efe0379d266179b8f
internal-packages/run-store/src/PostgresRunStore.tshttps://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-9c06c7000b359bcaa2f0b637af253ebfe2e2d9cf43568e42592b0e26f6910258
View file https://github.com/Jaimin2687/trigger.dev/blob/54a6df6e98a65efecc4399ecc68aa58ff1ceedd4/internal-packages/run-store/src/PostgresRunStore.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4818/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-9c06c7000b359bcaa2f0b637af253ebfe2e2d9cf43568e42592b0e26f6910258
https://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-9c06c7000b359bcaa2f0b637af253ebfe2e2d9cf43568e42592b0e26f6910258
internal-packages/run-store/src/types.tshttps://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-3b72267802fbd082b93adb08e3e014e75f40eb755c8a4f14bd7a76148f49ffe8
View file https://github.com/Jaimin2687/trigger.dev/blob/54a6df6e98a65efecc4399ecc68aa58ff1ceedd4/internal-packages/run-store/src/types.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4818/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-3b72267802fbd082b93adb08e3e014e75f40eb755c8a4f14bd7a76148f49ffe8
https://github.com/triggerdotdev/trigger.dev/pull/4818/files#diff-3b72267802fbd082b93adb08e3e014e75f40eb755c8a4f14bd7a76148f49ffe8
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.