bug: dashboard File column mis-attributes a task that is imported by another task file
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
- #4504 của @okxint — đã đóng, không merge
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- node.js, typescript
- Lĩnh vực
- build-system, tooling
Hướng nghiên cứu
Start by reading packages/cli-v3/src/build/bundle.ts and packages/cli-v3/src/indexing/registerResources.ts to follow how build outputs are imported and file context is set; then inspect registerTaskMetadata in packages/core/src/v3/resource-catalog/standardResourceCatalog.ts. Reproduce with the child.ts and parent.ts example in the issue. Done means the dashboard File column and task filePath identify the file where each task is defined, including when another task imports it.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Provide environment information
System:
OS: Windows 11 10.0.26200
CPU: (4) x64 Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
Memory: 4.71 GB / 15.95 GB
Binaries:
Node: 22.16.0
npm: 10.9.2
Packages:
trigger.dev CLI: 4.5.8
@trigger.dev/sdk: 4.5.8
runtime: node-22
Describe the bug
The File column in the dashboard's task list (and the corresponding filePath on the task) shows the wrong file for any task that is statically imported by another task file. It reports the importing file rather than the file the task is defined in.
Concretely, in my project the task enrich-company-record is defined in trigger/enrich-company-record.ts, but the dashboard lists it under trigger/reconcile-harmonic-watchlist.ts — one of five other task files that import a helper from it.
Expected: the file the task is defined in.
Impact is cosmetic — routing/execution keys off the task id, so nothing misbehaves at runtime; it's just a wrong file reference/deep-link in the UI. Filing it because the cause turned out to be precise.
Cause
The build runs esbuild with splitting: true (packages/cli-v3/src/build/bundle.ts). Every file under a dirs entry is its own entry point, so a task module that is also imported by sibling task files gets hoisted into a shared chunk instead of staying in its own entry bundle.
Indexing then imports each build entry in order, setting a file context around the import:
// packages/cli-v3/src/indexing/registerResources.ts
for (const file of buildManifest.files) {
resourceCatalog.setCurrentFileContext(file.entry, file.out);
const [error, _] = await tryImport(file.out);
resourceCatalog.clearCurrentFileContext();
...
}
and whatever registers during that import is stamped with that entry's path:
// packages/core/src/v3/resource-catalog/standardResourceCatalog.ts — registerTaskMetadata
this._taskFileMetadata.set(task.id, { ...this._currentFileContext });
buildManifest.files is built by iterating result.metafile.outputs, which is not the sorted entry-point order. So the shared chunk — and with it the task() call — evaluates during whichever importing entry happens to come first, and that entry wins the attribution. The task's own entry point is imported later, but the chunk is already in the ESM module cache, so it never re-registers and the attribution is never corrected.
In my build, trigger/reconcile-harmonic-watchlist.ts was index 3 in metafile.outputs and trigger/enrich-company-record.ts was index 31 — hence the observed mis-attribution. Confirmed by inspecting a trigger deploy --dry-run build: the schemaTask({ id: "enrich-company-record" }) call is emitted into a shared chunk-*.mjs, which trigger/reconcile-harmonic-watchlist.mjs imports.
A sibling task in the same project that nothing imports (dedupe-deals-list-entry, triggered only by id) stays in its own entry bundle and is attributed correctly — consistent with the above.
Code is unchanged on v4.5.9.
Reproduction repo
n/a — my project is private, but it reproduces from an empty project with the two files below; happy to push a repro repo if that's needed.
To reproduce
Two task files where one imports the other:
// trigger/child.ts
import { task } from "@trigger.dev/sdk";
export const child = task({
id: "child",
run: async () => {},
});
export const fanChild = () => child.trigger({});
// trigger/parent.ts
import { task } from "@trigger.dev/sdk";
import { fanChild } from "./child";
export const parent = task({
id: "parent",
run: async () => {
await fanChild();
},
});
Deploy (or run trigger dev) and look at the task list: task child is listed with File = trigger/parent.ts.
Note the ordering is metafile.outputs order, not alphabetical, so which importer wins varies by project — with a single importer as above it is deterministic.
Additional information
The build metafile already carries the chunk → source mapping needed to resolve the true defining file, so attribution could be corrected post-index without changing the import strategy.
- Ngôn ngữ chính
- TypeScript
- Star
- 16.5k
- Fork
- 1.5k
- Merge trung bình
- 1 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 17
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của triggerdotdev/trigger.dev
-
bug: retry.fetch ignores the caller's abort signal and retries aborted requestsCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
triggerdotdev/trigger.dev#5116 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug: Chat transport crashes on Safari < 17.4: AbortSignal.any is not a functionCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
triggerdotdev/trigger.dev#5098 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug: Side menu items lose their active state on detail pagesCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
triggerdotdev/trigger.dev#5088 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug: RBAC loader logs "plugin found but failed to load" when @triggerdotdev/plugins is simply not installedCó thể làm lại được @itsfaryal đã nhận 17 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
triggerdotdev/trigger.dev#5083 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
triggerdotdev/trigger.dev#5072 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của triggerdotdev/trigger.dev
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug platform-android
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Termix-SSH/Mobile#146 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
devswha/herdr-web-ui#3875 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
area: runtime chore cli consistency dependencies developer-experience difficulty: easy discovery documentation enhancement good first issue help wanted hygiene json-output packaging priority: P3 tests version
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày