1- import { RunEngine , RunDuplicateIdempotencyKeyError } from "@internal/run-engine" ;
1+ import { RunDuplicateIdempotencyKeyError , RunEngine } from "@internal/run-engine" ;
22import {
33 IOPacket ,
44 packetRequiresOffloading ,
@@ -14,34 +14,33 @@ import {
1414 sanitizeQueueName ,
1515 stringifyDuration ,
1616} from "@trigger.dev/core/v3/isomorphic" ;
17- import { Prisma , TaskRun } from "@trigger.dev/database" ;
17+ import { Prisma } from "@trigger.dev/database" ;
1818import { env } from "~/env.server" ;
19- import { createTag , MAX_TAGS_PER_RUN } from "~/models/taskRunTag.server" ;
19+ import { createTags , MAX_TAGS_PER_RUN } from "~/models/taskRunTag.server" ;
2020import { AuthenticatedEnvironment } from "~/services/apiAuth.server" ;
2121import { autoIncrementCounter } from "~/services/autoIncrementCounter.server" ;
2222import { logger } from "~/services/logger.server" ;
2323import { getEntitlement } from "~/services/platform.v3.server" ;
2424import { parseDelay } from "~/utils/delays" ;
2525import { resolveIdempotencyKeyTTL } from "~/utils/idempotencyKeys.server" ;
2626import { handleMetadataPacket } from "~/utils/packets" ;
27- import { eventRepository } from "../eventRepository.server" ;
28- import { findCurrentWorkerFromEnvironment } from "../models/workerDeployment.server" ;
29- import { uploadPacketToObjectStore } from "../r2.server" ;
30- import { isFinalRunStatus } from "../taskStatus" ;
31- import { startActiveSpan } from "../tracer.server" ;
32- import { clampMaxDuration } from "../utils/maxDuration" ;
33- import { ServiceValidationError , WithRunEngine } from "./baseService.server" ;
27+ import { eventRepository } from "../../v3/eventRepository.server" ;
28+ import { findCurrentWorkerFromEnvironment } from "../../v3/models/workerDeployment.server" ;
29+ import { uploadPacketToObjectStore } from "../../v3/r2.server" ;
30+ import { getTaskEventStore } from "../../v3/taskEventStore.server" ;
31+ import { isFinalRunStatus } from "../../v3/taskStatus" ;
32+ import { startActiveSpan } from "../../v3/tracer.server" ;
33+ import { clampMaxDuration } from "../../v3/utils/maxDuration" ;
34+ import { ServiceValidationError , WithRunEngine } from "../../v3/services/baseService.server" ;
3435import {
3536 MAX_ATTEMPTS ,
3637 OutOfEntitlementError ,
3738 TriggerTaskServiceOptions ,
3839 TriggerTaskServiceResult ,
39- } from "./triggerTask.server" ;
40- import { WorkerGroupService } from "./worker/workerGroupService.server" ;
41- import { getTaskEventStore } from "../taskEventStore.server" ;
40+ } from "../../v3/services/triggerTask.server" ;
41+ import { WorkerGroupService } from "../../v3/services/worker/workerGroupService.server" ;
4242
43- /** @deprecated Use TriggerTaskService in `triggerTask.server.ts` instead. */
44- export class TriggerTaskServiceV2 extends WithRunEngine {
43+ export class RunEngineTriggerTaskService extends WithRunEngine {
4544 public async call ( {
4645 taskId,
4746 environment,
@@ -299,20 +298,13 @@ export class TriggerTaskServiceV2 extends WithRunEngine {
299298 span . setAttribute ( "queueName" , queueName ) ;
300299
301300 //upsert tags
302- let tags : { id : string ; name : string } [ ] = [ ] ;
303- const bodyTags =
304- typeof body . options ?. tags === "string" ? [ body . options . tags ] : body . options ?. tags ;
305- if ( bodyTags && bodyTags . length > 0 ) {
306- for ( const tag of bodyTags ) {
307- const tagRecord = await createTag ( {
308- tag,
309- projectId : environment . projectId ,
310- } ) ;
311- if ( tagRecord ) {
312- tags . push ( tagRecord ) ;
313- }
314- }
315- }
301+ const tags = await createTags (
302+ {
303+ tags : body . options ?. tags ,
304+ projectId : environment . projectId ,
305+ } ,
306+ this . _prisma
307+ ) ;
316308
317309 const depth = parentRun ? parentRun . depth + 1 : 0 ;
318310
@@ -372,6 +364,10 @@ export class TriggerTaskServiceV2 extends WithRunEngine {
372364 machine : body . options ?. machine ,
373365 priorityMs : body . options ?. priority ? body . options . priority * 1_000 : undefined ,
374366 releaseConcurrency : body . options ?. releaseConcurrency ,
367+ queueTimestamp :
368+ parentRun && body . options ?. resumeParentOnCompletion
369+ ? parentRun . queueTimestamp ?? undefined
370+ : undefined ,
375371 } ,
376372 this . _prisma
377373 ) ;
0 commit comments