Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/bundle-deterministic-file-order.md
Original file line number Diff line number Diff line change
@@ -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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Release note text describes internals instead of user impact

The release note for this change is written in implementation terms, naming internal mechanics (Object.entries in .changeset/bundle-deterministic-file-order.md:5) instead of a plain user-facing sentence, so shipped release notes will violate the repository's changeset writing rules.
Impact: Users reading the release notes see internal jargon rather than a clear description of what changed for them.

Rule from AGENTS.md on changeset wording

AGENTS.md states: "Write the description for users, not maintainers. Both changesets and .server-changes/ notes ship verbatim in user-visible release notes. Lead with what changed for the user - one plain sentence describing behavior, not implementation, and never naming internal tools or infra." The current note leads with "non-deterministic task-to-file attribution" and cites Object.entries iteration order and internal registration order.

Suggested change
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.
Tasks now consistently appear under the file they are defined in, instead of sometimes being grouped under a file that imports them.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

2 changes: 2 additions & 0 deletions packages/cli-v3/src/build/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ export async function getBundleResultFromBuild(
}
}

files.sort((a, b) => a.entry.localeCompare(b.entry));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Alphabetical sort makes attribution deterministic but not necessarily correct

Sorting files by entry path only guarantees a stable order; it does not guarantee that a file defining a task is imported before a file that imports it. registerResources (packages/cli-v3/src/indexing/registerResources.ts:11-14) attributes every task registered during an import to the currently-imported entry, so a parent file that sorts earlier than its child (e.g. trigger/a-parent.ts importing trigger/z-child.ts) will still claim the child's tasks. The PR makes the misattribution consistent rather than eliminating it; a real fix would need to attribute tasks by the source file recorded at registration time (or import leaf modules first based on the metafile import graph).

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


if (!configPath) {
return undefined;
}
Expand Down