diff --git a/apps/webapp/app/components/primitives/TreeView/TreeView.tsx b/apps/webapp/app/components/primitives/TreeView/TreeView.tsx index e6d48b8cc4..7a2e368bec 100644 --- a/apps/webapp/app/components/primitives/TreeView/TreeView.tsx +++ b/apps/webapp/app/components/primitives/TreeView/TreeView.tsx @@ -235,9 +235,11 @@ export function useTree({ getItemKey: (index) => state.visibleNodeIds[index], getScrollElement: () => parentRef.current, estimateSize: (index: number) => { + const treeItem = tree[index]; + if (!treeItem) return 0; return estimatedRowHeight({ - node: tree[index], - state: state.nodes[tree[index].id], + node: treeItem, + state: state.nodes[treeItem.id], index, }); }, diff --git a/apps/webapp/app/v3/services/resumeTaskDependency.server.ts b/apps/webapp/app/v3/services/resumeTaskDependency.server.ts index ac912f9049..fc970b31cd 100644 --- a/apps/webapp/app/v3/services/resumeTaskDependency.server.ts +++ b/apps/webapp/app/v3/services/resumeTaskDependency.server.ts @@ -63,7 +63,8 @@ export class ResumeTaskDependencyService extends BaseService { environmentId: dependency.taskRun.runtimeEnvironment.id, environmentType: dependency.taskRun.runtimeEnvironment.type, }, - dependentRun.concurrencyKey ?? undefined + dependentRun.concurrencyKey ?? undefined, + dependentRun.createdAt.getTime() ); } else { logger.debug("Task dependency resume: Attempt is not paused or there's no checkpoint event", { @@ -84,16 +85,20 @@ export class ResumeTaskDependencyService extends BaseService { return; } - await marqs?.replaceMessage(dependentRun.id, { - type: "RESUME", - completedAttemptIds: [sourceTaskAttemptId], - resumableAttemptId: dependency.dependentAttempt.id, - checkpointEventId: dependency.checkpointEventId ?? undefined, - taskIdentifier: dependency.taskRun.taskIdentifier, - projectId: dependency.taskRun.runtimeEnvironment.projectId, - environmentId: dependency.taskRun.runtimeEnvironment.id, - environmentType: dependency.taskRun.runtimeEnvironment.type, - }); + await marqs?.replaceMessage( + dependentRun.id, + { + type: "RESUME", + completedAttemptIds: [sourceTaskAttemptId], + resumableAttemptId: dependency.dependentAttempt.id, + checkpointEventId: dependency.checkpointEventId ?? undefined, + taskIdentifier: dependency.taskRun.taskIdentifier, + projectId: dependency.taskRun.runtimeEnvironment.projectId, + environmentId: dependency.taskRun.runtimeEnvironment.id, + environmentType: dependency.taskRun.runtimeEnvironment.type, + }, + dependentRun.createdAt.getTime() + ); } } diff --git a/references/hello-world/src/trigger/prioritize-continuing.ts b/references/hello-world/src/trigger/prioritize-continuing.ts new file mode 100644 index 0000000000..1ae26754a0 --- /dev/null +++ b/references/hello-world/src/trigger/prioritize-continuing.ts @@ -0,0 +1,27 @@ +import { logger, task, wait } from "@trigger.dev/sdk/v3"; + +export const prioritizeContinuing = task({ + id: "prioritize-continuing", + run: async ({ count }: { count: number }) => { + await prioritizeContinuingChild.batchTrigger( + Array.from({ length: count }, (_, i) => ({ payload: {} as any })) + ); + }, +}); + +export const prioritizeContinuingChild = task({ + id: "prioritize-continuing-child", + queue: { + concurrencyLimit: 1, + }, + run: async () => { + await fixedLengthTask.triggerAndWait({ waitSeconds: 1 }); + }, +}); + +export const fixedLengthTask = task({ + id: "fixedLengthTask", + run: async ({ waitSeconds }: { waitSeconds: number }) => { + await new Promise((resolve) => setTimeout(resolve, waitSeconds * 1000)); + }, +});