trigger.dev
Version:
A Command-Line Interface for Trigger.dev (v3) projects
125 lines (124 loc) • 4.58 kB
TypeScript
import { ExecutorToWorkerMessageCatalog, ServerBackgroundWorker, TaskRunExecutionPayload, TaskRunExecutionResult, type TaskRunInternalError, WorkerManifest } from "@trigger.dev/core/v3";
import { Evt } from "evt";
import { InferSocketMessageSchema } from "@trigger.dev/core/v3/zodSocket";
export type OnWaitForDurationMessage = InferSocketMessageSchema<typeof ExecutorToWorkerMessageCatalog, "WAIT_FOR_DURATION">;
export type OnWaitForTaskMessage = InferSocketMessageSchema<typeof ExecutorToWorkerMessageCatalog, "WAIT_FOR_TASK">;
export type OnWaitForBatchMessage = InferSocketMessageSchema<typeof ExecutorToWorkerMessageCatalog, "WAIT_FOR_BATCH">;
export type TaskRunProcessOptions = {
workerManifest: WorkerManifest;
serverWorker: ServerBackgroundWorker;
env: Record<string, string>;
payload: TaskRunExecutionPayload;
messageId: string;
cwd?: string;
};
export declare class TaskRunProcess {
#private;
readonly options: TaskRunProcessOptions;
private _ipc?;
private _child;
private _childPid?;
private _attemptPromises;
private _attemptStatuses;
private _currentExecution;
private _gracefulExitTimeoutElapsed;
private _isBeingKilled;
private _isBeingCancelled;
private _stderr;
onTaskRunHeartbeat: Evt<string>;
onExit: Evt<{
code: number | null;
signal: NodeJS.Signals | null;
pid?: number;
}>;
onIsBeingKilled: Evt<TaskRunProcess>;
onReadyToDispose: Evt<TaskRunProcess>;
onWaitForDuration: Evt<OnWaitForDurationMessage>;
onWaitForTask: Evt<OnWaitForTaskMessage>;
onWaitForBatch: Evt<OnWaitForBatchMessage>;
constructor(options: TaskRunProcessOptions);
cancel(): Promise<void>;
cleanup(kill?: boolean): Promise<void>;
get runId(): string;
get isTest(): boolean;
get payload(): {
execution: {
task: {
id: string;
filePath: string;
exportName: string;
};
attempt: {
number: number;
status: string;
id: string;
startedAt: Date;
backgroundWorkerId: string;
backgroundWorkerTaskId: string;
};
run: {
payload: string;
id: string;
payloadType: string;
tags: string[];
isTest: boolean;
createdAt: Date;
startedAt: Date;
durationMs: number;
costInCents: number;
baseCostInCents: number;
metadata?: Record<string, import("@trigger.dev/core/schemas").DeserializedJson> | undefined;
context?: any;
idempotencyKey?: string | undefined;
maxAttempts?: number | undefined;
version?: string | undefined;
maxDuration?: number | undefined;
};
queue: {
name: string;
id: string;
};
environment: {
type: "PRODUCTION" | "STAGING" | "DEVELOPMENT" | "PREVIEW";
id: string;
slug: string;
};
organization: {
name: string;
id: string;
slug: string;
};
project: {
name: string;
id: string;
slug: string;
ref: string;
};
batch?: {
id: string;
} | undefined;
machine?: {
cpu: number;
memory: number;
name: "micro" | "small-1x" | "small-2x" | "medium-1x" | "medium-2x" | "large-1x" | "large-2x";
centsPerMs: number;
} | undefined;
};
traceContext: Record<string, unknown>;
environment?: Record<string, string> | undefined;
metrics?: {
name: string;
timestamp: number;
event: string;
duration: number;
}[] | undefined;
};
initialize(): Promise<void>;
execute(): Promise<TaskRunExecutionResult>;
taskRunCompletedNotification(completion: TaskRunExecutionResult): void;
waitCompletedNotification(): void;
kill(signal?: number | NodeJS.Signals, timeoutInMs?: number): Promise<void>;
get isBeingKilled(): boolean | undefined;
get pid(): number | undefined;
static parseExecuteError(error: unknown, dockerMode?: boolean): TaskRunInternalError;
}