René's URL Explorer Experiment


Title: fix(batchTrigger): clear idempotency key when previous run failed (closes #4819) by 61465 · Pull Request #5014 · triggerdotdev/trigger.dev · GitHub

Open Graph Title: fix(batchTrigger): clear idempotency key when previous run failed (closes #4819) by 61465 · Pull Request #5014 · triggerdotdev/trigger.dev

X Title: fix(batchTrigger): clear idempotency key when previous run failed (closes #4819) by 61465 · Pull Request #5014 · triggerdotdev/trigger.dev

Description: What Fixes #4819 — batchTrigger silently returned stale failed runs as isCached: true, so a caller re-batching with the same idempotency key never got a retry. The single-trigger path has done the right thing since day one via IdempotencyKeyConcern.handleExistingRun → shouldIdempotencyKeyBeCleared (apps/webapp/app/runEngine/concerns/idempotencyKeys.server.ts:463). The batch path at batchTriggerV3.server.ts:450 just ignored the status. Repro from the issue (confirmed): const failingTask = task({ id: 'failing-task', run: async () => { throw new Error('boom') }, }) // First batchTrigger — run fails and ends up CRASHED await tasks.batchTrigger('failing-task', [ { payload: {}, options: { idempotencyKey: 'key-1' } }, ]) // …wait for CRASHED… // Second batchTrigger with the same key const res = await tasks.batchTrigger('failing-task', [ { payload: {}, options: { idempotencyKey: 'key-1' } }, ]) // Expected: isCached: false (fresh run) // Actual: isCached: true (dead CRASHED run handed back) Root cause Credit to @Jaimin2687 for the full RCA on the issue. Confirmed line-by-line: PostgresRunStore.findRunsByIdempotencyKeys SELECTs 5 columns — id, createdAt, friendlyId, idempotencyKey, idempotencyKeyExpiresAt. status was missing from both the SQL and the IdempotencyKeyRunMatch type. #prepareRunData therefore had only time-based expiry to work with and no way to see that the cached run was CRASHED / COMPLETED_WITH_ERRORS / SYSTEM_FAILURE / INTERRUPTED / TIMED_OUT_WITH_ERRORS / EXPIRED. Fix (additive, 4 files) internal-packages/run-store/src/types.ts Adds status: TaskRunStatus to IdempotencyKeyRunMatch, with a comment explaining why the field is now required. internal-packages/run-store/src/PostgresRunStore.ts Hot-path UNION ALL SQL now also selects \"status\". One token added per branch, no new rows read, no index change — the existing (runtimeEnvironmentId, taskIdentifier, idempotencyKey) filter already pinpoints each row. apps/webapp/app/v3/services/batchTriggerV3.server.ts #prepareRunData imports shouldIdempotencyKeyBeCleared and ORs it with the existing time-expiry check. A cached run whose status is in the 'clear me' set is now treated exactly like an expired cache entry: the friendlyId is added to expiredRunIds for cleanup, a fresh child id is minted, and the result returns with isCached: false. Behaviour on cached-but-still-good runs is unchanged. Behaviour on cached-and-time-expired runs is unchanged. Only the previously-silent "cached but dead" case flips. internal-packages/run-store/src/PostgresRunStore.findRunsByIdempotencyKeys.test.ts createRun helper gains an optional status param. New postgresTest(\"returns run status so callers can honour shouldIdempotencyKeyBeCleared\") creates four seed rows (PENDING, CRASHED, COMPLETED_WITH_ERRORS, COMPLETED_SUCCESSFULLY) and asserts the store surfaces each status in the result. This locks the contract for batchTrigger to depend on. Why this design Minimal diff: one extra column in a SQL, one extra OR in the batch path, one type field, one test. No refactor of the batch flow, no new code path to maintain. Mirrors the single-trigger contract: anyone reading shouldIdempotencyKeyBeCleared as the source of truth already expects both call sites to behave the same way. This PR makes them so. Fail-closed: on an unexpected status value the OR evaluates to false and we fall through to the existing "return cached" path — identical behaviour to today. No API shape change: BatchTriggerTaskV2Response already carries isCached per item. Callers that previously got isCached: true for a dead run will now get isCached: false and a fresh friendlyId, which is what they already handle for the time-expired case. Testing Added postgres-backed vitest proves the SQL now returns status. Existing tests still pass (no behavioural change for cached-good runs). Impact Any user of batchTrigger + idempotency keys on failing tasks: silently broken today, silently fixed by this PR. The failure mode is nasty because the caller sees isCached: true and reasonably assumes the run will produce output — then waits forever on a dead run. Shipping-visible to all self-hosted and cloud users of SDK 4.5.11+. Related Reporter: @Jaimin2687 — full RCA + line references on the issue. Prior work this builds on: shouldIdempotencyKeyBeCleared was introduced in the single-trigger path to codify the retry-on-failure contract. This PR extends the same contract to the batch path.

Open Graph Description: What Fixes #4819 — batchTrigger silently returned stale failed runs as isCached: true, so a caller re-batching with the same idempotency key never got a retry. The single-trigger path has done the ...

X Description: What Fixes #4819 — batchTrigger silently returned stale failed runs as isCached: true, so a caller re-batching with the same idempotency key never got a retry. The single-trigger path has done the ...

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

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:c3f6707c-bc82-a23d-e529-060089d587fd
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idC0E6:249B37:43B1A6F:5B50D39:6AFADAC9
html-safe-nonce766b047e7a16aeb0d4c1592cd1b9a5dc8242c87f3caf5605412435030547309e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMEU2OjI0OUIzNzo0M0IxQTZGOjVCNTBEMzk6NkFGQURBQzkiLCJ2aXNpdG9yX2lkIjoiNTM3ODY0OTYyMTczNzk1Mzk5MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacea5e7b89709b93e55047a3fdb1b420e069d115b07ca457f51eedd4da6f392dd2
hovercard-subject-tagpull_request:4813181921
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/5014/files
twitter:imagehttps://avatars.githubusercontent.com/u/62155637?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/62155637?s=400&v=4
og:image:altWhat Fixes #4819 — batchTrigger silently returned stale failed runs as isCached: true, so a caller re-batching with the same idempotency key never got a retry. The single-trigger path has done the ...
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/5014/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fpull%2F5014%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%2F5014%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/5014/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/5014/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/5014/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 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
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
61465https://github.com/61465
triggerdotdev:mainhttps://github.com/triggerdotdev/trigger.dev/tree/main
61465:fix/batch-trigger-idempotency-dead-runs-4819https://github.com/61465/trigger.dev/tree/fix/batch-trigger-idempotency-dead-runs-4819
Conversation 9 https://github.com/triggerdotdev/trigger.dev/pull/5014
Commits 1 https://github.com/triggerdotdev/trigger.dev/pull/5014/commits
Checks 2 https://github.com/triggerdotdev/trigger.dev/pull/5014/checks
Files changed https://github.com/triggerdotdev/trigger.dev/pull/5014/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/5014/files
fix(batchTrigger): clear idempotency key when previous run failed (closes #4819) https://github.com/triggerdotdev/trigger.dev/pull/5014/files#top
Show all changes 1 commit https://github.com/triggerdotdev/trigger.dev/pull/5014/files
a39efeb fix(batchTrigger): clear idempotency key when previous run failed (cl… 61465 Oct 10, 2026 https://github.com/triggerdotdev/trigger.dev/pull/5014/commits/a39efebbe0cd812368df44985539c1cf9a73c9c6
Clear filters https://github.com/triggerdotdev/trigger.dev/pull/5014/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/5014/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/5014/files
batchTriggerV3.server.ts https://github.com/triggerdotdev/trigger.dev/pull/5014/files#diff-55867b934007572d29b5479a4721efceb9743d246bfaf3a4401371bab53beebd
PostgresRunStore.findRunsByIdempotencyKeys.test.ts https://github.com/triggerdotdev/trigger.dev/pull/5014/files#diff-99988478d8eff178f7816d114388452cf309398e58ad837efe0379d266179b8f
PostgresRunStore.ts https://github.com/triggerdotdev/trigger.dev/pull/5014/files#diff-9c06c7000b359bcaa2f0b637af253ebfe2e2d9cf43568e42592b0e26f6910258
types.ts https://github.com/triggerdotdev/trigger.dev/pull/5014/files#diff-3b72267802fbd082b93adb08e3e014e75f40eb755c8a4f14bd7a76148f49ffe8
apps/webapp/app/v3/services/batchTriggerV3.server.tshttps://github.com/triggerdotdev/trigger.dev/pull/5014/files#diff-55867b934007572d29b5479a4721efceb9743d246bfaf3a4401371bab53beebd
View file https://github.com/61465/trigger.dev/blob/a39efebbe0cd812368df44985539c1cf9a73c9c6/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/5014/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/5014/files#diff-55867b934007572d29b5479a4721efceb9743d246bfaf3a4401371bab53beebd
https://github.com/triggerdotdev/trigger.dev/pull/5014/files#diff-55867b934007572d29b5479a4721efceb9743d246bfaf3a4401371bab53beebd
https://github.com/triggerdotdev/trigger.dev/pull/5014/files#diff-55867b934007572d29b5479a4721efceb9743d246bfaf3a4401371bab53beebd
devin-ai-integrationhttps://github.com/apps/devin-ai-integration
Oct 10, 2026https://github.com/triggerdotdev/trigger.dev/pull/5014/files#r4238591504
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
https://app.devin.ai/review/triggerdotdev/trigger.dev/pull/5014
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/5014/files
devin-ai-integrationhttps://github.com/apps/devin-ai-integration
Oct 10, 2026https://github.com/triggerdotdev/trigger.dev/pull/5014/files#r4238591398
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
https://app.devin.ai/review/triggerdotdev/trigger.dev/pull/5014
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/5014/files
devin-ai-integrationhttps://github.com/apps/devin-ai-integration
Oct 10, 2026https://github.com/triggerdotdev/trigger.dev/pull/5014/files#r4238591340
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
this codehttps://github.com/triggerdotdev/trigger.dev/blob/a39efebbe0cd812368df44985539c1cf9a73c9c6/apps/webapp/app/v3/services/batchTriggerV3.server.ts#L472-L479
#processBatchTaskRunItemhttps://github.com/triggerdotdev/trigger.dev/blob/a39efebbe0cd812368df44985539c1cf9a73c9c6/apps/webapp/app/v3/services/batchTriggerV3.server.ts#L914-L985
handleTriggerRequesthttps://github.com/triggerdotdev/trigger.dev/blob/a39efebbe0cd812368df44985539c1cf9a73c9c6/apps/webapp/app/runEngine/concerns/idempotencyKeys.server.ts#L200-L243
https://app.devin.ai/review/triggerdotdev/trigger.dev/pull/5014
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/5014/files
https://github.com/triggerdotdev/trigger.dev/pull/5014/files#diff-55867b934007572d29b5479a4721efceb9743d246bfaf3a4401371bab53beebd
internal-packages/run-store/src/PostgresRunStore.findRunsByIdempotencyKeys.test.tshttps://github.com/triggerdotdev/trigger.dev/pull/5014/files#diff-99988478d8eff178f7816d114388452cf309398e58ad837efe0379d266179b8f
View file https://github.com/61465/trigger.dev/blob/a39efebbe0cd812368df44985539c1cf9a73c9c6/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/5014/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/5014/files#diff-99988478d8eff178f7816d114388452cf309398e58ad837efe0379d266179b8f
https://github.com/triggerdotdev/trigger.dev/pull/5014/files#diff-99988478d8eff178f7816d114388452cf309398e58ad837efe0379d266179b8f
https://github.com/triggerdotdev/trigger.dev/pull/5014/files#diff-99988478d8eff178f7816d114388452cf309398e58ad837efe0379d266179b8f
https://github.com/triggerdotdev/trigger.dev/pull/5014/files#diff-99988478d8eff178f7816d114388452cf309398e58ad837efe0379d266179b8f
https://github.com/triggerdotdev/trigger.dev/pull/5014/files#diff-99988478d8eff178f7816d114388452cf309398e58ad837efe0379d266179b8f
devin-ai-integrationhttps://github.com/apps/devin-ai-integration
Oct 10, 2026https://github.com/triggerdotdev/trigger.dev/pull/5014/files#r4238591464
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
https://app.devin.ai/review/triggerdotdev/trigger.dev/pull/5014
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/5014/files
internal-packages/run-store/src/PostgresRunStore.tshttps://github.com/triggerdotdev/trigger.dev/pull/5014/files#diff-9c06c7000b359bcaa2f0b637af253ebfe2e2d9cf43568e42592b0e26f6910258
View file https://github.com/61465/trigger.dev/blob/a39efebbe0cd812368df44985539c1cf9a73c9c6/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/5014/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/5014/files#diff-9c06c7000b359bcaa2f0b637af253ebfe2e2d9cf43568e42592b0e26f6910258
https://github.com/triggerdotdev/trigger.dev/pull/5014/files#diff-9c06c7000b359bcaa2f0b637af253ebfe2e2d9cf43568e42592b0e26f6910258
internal-packages/run-store/src/types.tshttps://github.com/triggerdotdev/trigger.dev/pull/5014/files#diff-3b72267802fbd082b93adb08e3e014e75f40eb755c8a4f14bd7a76148f49ffe8
View file https://github.com/61465/trigger.dev/blob/a39efebbe0cd812368df44985539c1cf9a73c9c6/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/5014/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/5014/files#diff-3b72267802fbd082b93adb08e3e014e75f40eb755c8a4f14bd7a76148f49ffe8
https://github.com/triggerdotdev/trigger.dev/pull/5014/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.