From 4d5d5f1901ca01a021e4325f40210e4a37582b91 Mon Sep 17 00:00:00 2001 From: CahidArda Date: Tue, 20 Jan 2026 18:13:13 +0300 Subject: [PATCH] fix: rm check wf start with eventually, I believe this resulted in canceling workflow runs before they could start and caused errors in qstash tests --- examples/ci/app/ci/upstash/qstash.ts | 17 ------------- examples/ci/app/ci/utils.ts | 37 ---------------------------- 2 files changed, 54 deletions(-) diff --git a/examples/ci/app/ci/upstash/qstash.ts b/examples/ci/app/ci/upstash/qstash.ts index f82d9b02..24a340eb 100644 --- a/examples/ci/app/ci/upstash/qstash.ts +++ b/examples/ci/app/ci/upstash/qstash.ts @@ -32,23 +32,6 @@ export const startWorkflow = async ( return result } -/** - * throws error if workflow hasn't started - * - * @param messageId - * @returns - */ -export const checkWorkflowStart = async (workflowRunId: string) => { - - const results = await workflowClient.logs({ workflowRunId }) - const firstRun = results.runs[0] - const startMessageDelivered = firstRun && firstRun.steps.length > 1 - if (!startMessageDelivered) { - await workflowClient.cancel({ ids: [ workflowRunId ] }) - throw new Error(firstRun ? `Couldn't verify that workflow has begun. Number of steps: ${firstRun.steps.length}` : "No runs found") - } -} - export const getWorkflowLogs = async (workflowRunId: string) => { const results = await workflowClient.logs({ workflowRunId }) return results diff --git a/examples/ci/app/ci/utils.ts b/examples/ci/app/ci/utils.ts index de36ca78..d82bd822 100644 --- a/examples/ci/app/ci/utils.ts +++ b/examples/ci/app/ci/utils.ts @@ -72,17 +72,6 @@ export const initiateTest = async (params: Pick) => { // sleep for 4 secs and check that message is delivered await new Promise(r => setTimeout(r, CHECK_WF_AFTER_INIT_DURATION)); - try { - await eventually(async () => { - await qstash.checkWorkflowStart(workflowRunId); - }) - } catch (error) { - console.error(error); - if (shouldWorkflowStart) { - throw error; - }; - } - try { await redis.checkRedisForResults(route, randomTestId, expectedCallCount, expectedResult) } catch (error) { @@ -121,29 +110,3 @@ export const expect = ( throw new Error(`Unexpected value.\n\tReceived "${received}"\n\tExpected "${expected}"`) } } - -export const eventually = async function ( - fn: () => Promise | void, - options: { - timeout?: number; - interval?: number; - } = {} -): Promise { - const { timeout = 5000, interval = 100 } = options; - - const startTime = Date.now(); - - while (true) { - try { - await fn(); - // Success case - all assertions passed - return; - } catch (error) { - const lastError = error as Error; - if (Date.now() - startTime >= timeout) { - throw new Error(`Assertions not satisfied within timeout: ${lastError.message}`); - } - await new Promise((resolve) => setTimeout(resolve, interval)); - } - } -};