MCPcopy Index your code
hub / github.com/coder/mux / waitForRouterWorkflowStatus

Function waitForRouterWorkflowStatus

src/node/orpc/router.test.ts:73–93  ·  view source on GitHub ↗
(
  client: {
    workflows: {
      getRun(input: { workspaceId: string; runId: string }): Promise<{ status: string } | null>;
    };
  },
  workspaceId: string,
  runId: string,
  status: string
)

Source from the content-addressed store, hash-verified

71}
72
73async function waitForRouterWorkflowStatus(
74 client: {
75 workflows: {
76 getRun(input: { workspaceId: string; runId: string }): Promise<{ status: string } | null>;
77 };
78 },
79 workspaceId: string,
80 runId: string,
81 status: string
82): Promise<void> {
83 const deadline = Date.now() + 1_000;
84 while (Date.now() < deadline) {
85 const run = await client.workflows.getRun({ workspaceId, runId });
86 if (run?.status === status) {
87 return;
88 }
89 await new Promise((resolve) => setTimeout(resolve, 10));
90 }
91 const run = await client.workflows.getRun({ workspaceId, runId });
92 throw new Error(`Timed out waiting for ${runId} to become ${status}; got ${run?.status}`);
93}
94
95describe("router workflow routes", () => {
96 let tempDir: string;

Callers 1

router.test.tsFile · 0.85

Calls 1

getRunMethod · 0.65

Tested by

no test coverage detected