(
executionArn: string,
stack: { region: string; functionName: string; lambdaMemoryMb: number },
intervalMs: number,
json: boolean,
)
| 185 | } |
| 186 | |
| 187 | async function waitForCompletion( |
| 188 | executionArn: string, |
| 189 | stack: { region: string; functionName: string; lambdaMemoryMb: number }, |
| 190 | intervalMs: number, |
| 191 | json: boolean, |
| 192 | ): Promise<void> { |
| 193 | // Lazy import to avoid pulling SFN client when only `render --no-wait` is used. |
| 194 | const { getRenderProgress } = await loadSDK(); |
| 195 | let lastRendered = -1; |
| 196 | while (true) { |
| 197 | const progress = await getRenderProgress({ |
| 198 | executionArn, |
| 199 | region: stack.region, |
| 200 | defaultMemorySizeMb: stack.lambdaMemoryMb, |
| 201 | }); |
| 202 | if (!json && progress.framesRendered !== lastRendered) { |
| 203 | lastRendered = progress.framesRendered; |
| 204 | const total = progress.totalFrames ?? "?"; |
| 205 | const pct = Math.round(progress.overallProgress * 100); |
| 206 | console.log( |
| 207 | ` ${c.dim(`[${progress.status}]`)} ${pct}% • ${progress.framesRendered}/${total} frames • ${progress.costs.displayCost}`, |
| 208 | ); |
| 209 | } |
| 210 | if (progress.status !== "RUNNING") { |
| 211 | if (json) { |
| 212 | console.log(JSON.stringify(progress, null, 2)); |
| 213 | } else if (progress.status === "SUCCEEDED" && progress.outputFile) { |
| 214 | console.log(); |
| 215 | console.log(c.success("Render complete.")); |
| 216 | console.log(` ${c.dim("Output:")} ${progress.outputFile.s3Uri}`); |
| 217 | console.log(` ${c.dim("Size:")} ${progress.outputFile.bytes ?? "?"} bytes`); |
| 218 | console.log(` ${c.dim("Total cost:")} ${progress.costs.displayCost}`); |
| 219 | } else { |
| 220 | console.log(); |
| 221 | console.log(c.error(`Render ended with status ${progress.status}.`)); |
| 222 | for (const err of progress.errors) { |
| 223 | console.log(` ${c.dim(err.state)}: ${err.error} — ${err.cause}`); |
| 224 | } |
| 225 | process.exitCode = 1; |
| 226 | } |
| 227 | return; |
| 228 | } |
| 229 | await sleep(intervalMs); |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | function sleep(ms: number): Promise<void> { |
| 234 | return new Promise((res) => setTimeout(res, ms)); |
no test coverage detected