From 5e1f25f3c0754bfe3c3fa00de8dda079991d28cb Mon Sep 17 00:00:00 2001 From: okxint Date: Wed, 5 Aug 2026 10:54:16 +0530 Subject: [PATCH] fix(cli): sort bundle files by entry path for deterministic task attribution --- .changeset/bundle-deterministic-file-order.md | 5 +++++ packages/cli-v3/src/build/bundle.ts | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 .changeset/bundle-deterministic-file-order.md diff --git a/.changeset/bundle-deterministic-file-order.md b/.changeset/bundle-deterministic-file-order.md new file mode 100644 index 00000000000..d8e7a0ca264 --- /dev/null +++ b/.changeset/bundle-deterministic-file-order.md @@ -0,0 +1,5 @@ +--- +"trigger.dev": patch +--- + +Fix non-deterministic task-to-file attribution when multiple tasks share an output bundle. `Object.entries` iteration order is not guaranteed, so tasks defined in imported files could be attributed to the wrong source file. Files are now sorted by entry path before registration. diff --git a/packages/cli-v3/src/build/bundle.ts b/packages/cli-v3/src/build/bundle.ts index 4d1cfd53f86..a0197934a8a 100644 --- a/packages/cli-v3/src/build/bundle.ts +++ b/packages/cli-v3/src/build/bundle.ts @@ -307,6 +307,8 @@ export async function getBundleResultFromBuild( } } + files.sort((a, b) => a.entry.localeCompare(b.entry)); + if (!configPath) { return undefined; }