fix(typescript-client): runFlowAsync by default assume job doesn't outlive flow

This commit is contained in:
Ruben Fiszel
2024-08-19 17:03:06 +02:00
committed by GitHub
parent 7fe0442a81
commit 010e0fdc23
+8 -5
View File
@@ -134,7 +134,7 @@ export async function runFlow(
console.info(`running \`${path}\` synchronously with args:`, args);
}
const jobId = await runFlowAsync(path, args);
const jobId = await runFlowAsync(path, args, null, true);
return await waitJob(jobId, verbose);
}
@@ -272,7 +272,8 @@ export async function runScriptAsync(
export async function runFlowAsync(
path: string | null,
args: Record<string, any> | null,
scheduledInSeconds: number | null = null
scheduledInSeconds: number | null = null,
flowOutlivesParent: boolean = false
): Promise<string> {
// Create a script job and return its job id.
@@ -283,9 +284,11 @@ export async function runFlowAsync(
params["scheduled_in_secs"] = scheduledInSeconds;
}
let parentJobId = getEnv("WM_JOB_ID");
if (parentJobId !== undefined) {
params["parent_job"] = parentJobId;
if (flowOutlivesParent) {
let parentJobId = getEnv("WM_JOB_ID");
if (parentJobId !== undefined) {
params["parent_job"] = parentJobId;
}
}
let rootJobId = getEnv("WM_ROOT_FLOW_JOB_ID");