Skip to content

Commit c116441

Browse files
committed
Temporary debugging
1 parent ac2e367 commit c116441

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

src/integration-tests/utils/waitForWorkflowStatus.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { WorkflowExecutor } from "../../sdk";
44
/**
55
* Wait for workflow to reach expected status
66
*/
7+
const LOG_INTERVAL_MS = 15000;
8+
79
export const waitForWorkflowStatus = async (
810
workflowClient: WorkflowExecutor,
911
workflowId: string,
@@ -12,13 +14,21 @@ export const waitForWorkflowStatus = async (
1214
pollIntervalMs = 3000
1315
): Promise<Workflow> => {
1416
const startTime = Date.now();
17+
let lastLogTime = 0;
18+
let lastStatus: string | undefined;
1519

1620
let lastError: unknown;
1721
while (Date.now() - startTime < maxWaitTimeMs) {
1822
try {
1923
const workflow = await workflowClient.getWorkflow(workflowId, true);
24+
const elapsed = Date.now() - startTime;
2025

2126
if (workflow?.status === expectedStatus) {
27+
if (process.env.CI && elapsed > 0) {
28+
console.log(
29+
`[waitForWorkflowStatus] workflowId=${workflowId} reached ${expectedStatus} in ${elapsed}ms`
30+
);
31+
}
2232
return workflow;
2333
}
2434

@@ -28,6 +38,15 @@ export const waitForWorkflowStatus = async (
2838
);
2939
}
3040

41+
lastStatus = workflow?.status;
42+
43+
if (process.env.CI && Date.now() - lastLogTime >= LOG_INTERVAL_MS) {
44+
lastLogTime = Date.now();
45+
console.log(
46+
`[waitForWorkflowStatus] workflowId=${workflowId} status=${workflow?.status ?? "undefined"} elapsed=${elapsed}ms (waiting for ${expectedStatus})`
47+
);
48+
}
49+
3150
lastError = undefined;
3251
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
3352
} catch (error) {
@@ -41,7 +60,8 @@ export const waitForWorkflowStatus = async (
4160
throw new Error(`Failed to get workflow status: ${lastError}`);
4261
}
4362

63+
const lastStatusMsg = lastStatus !== undefined ? `; last status was ${lastStatus}` : "";
4464
throw new Error(
45-
`Workflow did not reach status ${expectedStatus} within ${maxWaitTimeMs}ms`
65+
`Workflow did not reach status ${expectedStatus} within ${maxWaitTimeMs}ms${lastStatusMsg}`
4666
);
4767
};

src/sdk/clients/worker/TaskRunner.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ export class TaskRunner {
197197

198198
while (retryCount < this.maxRetries) {
199199
try {
200+
if (process.env.CI) {
201+
console.log(
202+
`[TaskRunner] Submitting task result taskId=${taskResult.taskId} workflowId=${taskResult.workflowInstanceId} taskType=${this.worker.taskDefName} attempt=${retryCount + 1}/${this.maxRetries}`
203+
);
204+
}
200205
const updateStart = Date.now();
201206
const { data: nextTask } = await TaskResource.updateTaskV2({
202207
client: this._client,
@@ -207,6 +212,12 @@ export class TaskRunner {
207212
});
208213
const updateDurationMs = Date.now() - updateStart;
209214

215+
if (process.env.CI) {
216+
console.log(
217+
`[TaskRunner] Task result accepted taskId=${taskResult.taskId} durationMs=${updateDurationMs}`
218+
);
219+
}
220+
210221
await this.eventDispatcher.publishTaskUpdateCompleted({
211222
taskType: this.worker.taskDefName,
212223
taskId: taskResult.taskId ?? "",
@@ -304,6 +315,12 @@ export class TaskRunner {
304315
const workflowInstanceId = task.workflowInstanceId as string;
305316
const startTime = Date.now();
306317

318+
if (process.env.CI) {
319+
console.log(
320+
`[TaskRunner] Executing task taskId=${taskId} workflowId=${workflowInstanceId} taskType=${this.worker.taskDefName}`
321+
);
322+
}
323+
307324
// Publish TaskExecutionStarted event
308325
await this.eventDispatcher.publishTaskExecutionStarted({
309326
taskType: this.worker.taskDefName,

0 commit comments

Comments
 (0)