🎥 Make videos programmatically with React
just check for progress.json file
Jonny Burger09e206ec681f
diff --git a/packages/lambda/src/functions/helpers/check-if-render-exists.ts b/packages/lambda/src/functions/helpers/check-if-render-exists.tsdeleted file mode 100644index 79a5cd6045..0000000000--- a/packages/lambda/src/functions/helpers/check-if-render-exists.ts+++ /dev/null@@ -1,23 +0,0 @@-import type {_Object} from '@aws-sdk/client-s3';-import type {AwsRegion} from '../../client';-import {overallProgressKey} from '../../shared/constants';--export const checkIfRenderExists = (- contents: _Object[],- renderId: string,- bucketName: string,- region: AwsRegion,-) => {- const initializedExists = Boolean(- contents.find((c) => {- return c.Key?.startsWith(overallProgressKey(renderId));- }),- );-- if (!initializedExists) {- // ! Error message is checked in progress handler and will be retried. Make sure to update- throw new TypeError(- `No render with ID "${renderId}" found in bucket ${bucketName} and region ${region}`,- );- }-};diff --git a/packages/lambda/src/functions/helpers/get-overall-progress-s3.ts b/packages/lambda/src/functions/helpers/get-overall-progress-s3.tsindex eded951081..fbfe85bce0 100644--- a/packages/lambda/src/functions/helpers/get-overall-progress-s3.ts+++ b/packages/lambda/src/functions/helpers/get-overall-progress-s3.ts@@ -24,6 +24,12 @@ export const getOverallProgressS3 = async ({const str = await streamToString(Body);return JSON.parse(str) as OverallRenderProgress;} catch (err) {- return null;+ if ((err as Error).name === 'NotFound') {+ throw new TypeError(+ `No render with ID "${renderId}" found in bucket ${bucketName} and region ${getCurrentRegionInFunction()}`,+ );+ }++ throw err;}};diff --git a/packages/lambda/src/functions/helpers/get-progress.ts b/packages/lambda/src/functions/helpers/get-progress.tsindex 9e04ef0466..0d337632ea 100644--- a/packages/lambda/src/functions/helpers/get-progress.ts+++ b/packages/lambda/src/functions/helpers/get-progress.ts@@ -11,7 +11,6 @@ import {import {truthy} from '../../shared/truthy';import {calculateChunkTimes} from './calculate-chunk-times';import {estimatePriceFromBucket} from './calculate-price-from-bucket';-import {checkIfRenderExists} from './check-if-render-exists';import {getExpectedOutName} from './expected-out-name';import {findOutputFileInBucket} from './find-output-file-in-bucket';import {formatCostsInfo} from './format-costs-info';@@ -49,7 +48,7 @@ export const getProgress = async ({expectedBucketOwner,});- if (overallProgress?.postRenderData) {+ if (overallProgress.postRenderData) {const outData = getExpectedOutName(overallProgress.postRenderData.renderMetadata,bucketName,@@ -146,13 +145,6 @@ export const getProgress = async ({);}- checkIfRenderExists(- contents,- renderId,- bucketName,- getCurrentRegionInFunction(),- );-const outputFile = renderMetadata? await findOutputFileInBucket({bucketName,@@ -170,7 +162,7 @@ export const getProgress = async ({// We cannot determine the ephemeral storage size, so we// overestimate the price, but will only have a miniscule effect (~0.2%)diskSizeInMb: MAX_EPHEMERAL_STORAGE_IN_MB,- timings: overallProgress?.timings ?? [],+ timings: overallProgress.timings ?? [],});const {hasAudio, hasVideo} = renderMetadata@@ -191,7 +183,7 @@ export const getProgress = async ({const chunkMultiplier = [hasAudio, hasVideo].filter(truthy).length;const allChunks =- (overallProgress?.chunks ?? []).length / chunkMultiplier ===+ (overallProgress.chunks ?? []).length / chunkMultiplier ===(renderMetadata?.totalChunks ?? Infinity);const renderSize = contents.map((c) => c.Size ?? 0)@@ -204,14 +196,14 @@ export const getProgress = async ({).length: null;- const chunkCount = overallProgress?.chunks.length ?? 0;+ const chunkCount = overallProgress.chunks.length ?? 0;const missingChunks = renderMetadata? new Array(renderMetadata.totalChunks).fill(true).map((_, i) => i).filter((index) => {- return !(overallProgress?.chunks ?? []).find((c) => c === index);+ return !(overallProgress.chunks ?? []).find((c) => c === index);}): null;@@ -242,13 +234,13 @@ export const getProgress = async ({].filter(NoReactInternals.truthy);return {- framesRendered: overallProgress?.framesRendered ?? 0,+ framesRendered: overallProgress.framesRendered ?? 0,chunks: chunkCount,done: false,encodingStatus: {- framesEncoded: overallProgress?.framesEncoded ?? 0,- combinedFrames: overallProgress?.combinedFrames ?? 0,- timeToCombine: overallProgress?.timeToCombine ?? null,+ framesEncoded: overallProgress.framesEncoded ?? 0,+ combinedFrames: overallProgress.combinedFrames ?? 0,+ timeToCombine: overallProgress.timeToCombine ?? null,},costs: priceFromBucket? formatCostsInfo(priceFromBucket.accruedSoFar)@@ -262,7 +254,7 @@ export const getProgress = async ({fatalErrorEncountered: allErrors.some((f) => f.isFatal && !f.willRetry),currentTime: Date.now(),renderSize,- lambdasInvoked: overallProgress?.lambdasInvoked ?? 0,+ lambdasInvoked: overallProgress.lambdasInvoked ?? 0,cleanup,timeToFinishChunks:allChunks && overallProgress@@ -275,16 +267,16 @@ export const getProgress = async ({cleanup: cleanup ? cleanup.filesDeleted / cleanup.minFilesToDelete : 0,encoding:renderMetadata && frameCount- ? overallProgress?.framesEncoded ?? 0 / frameCount+ ? overallProgress.framesEncoded ?? 0 / frameCount: 0,invoking: renderMetadata- ? (overallProgress?.lambdasInvoked ?? 0) /+ ? (overallProgress.lambdasInvoked ?? 0) /renderMetadata.estimatedRenderLambdaInvokations: 0,rendering: renderMetadata ? chunkCount / renderMetadata.totalChunks : 0,- frames: (overallProgress?.framesRendered ?? 0) / (frameCount ?? 1),+ frames: (overallProgress.framesRendered ?? 0) / (frameCount ?? 1),}),- retriesInfo: overallProgress?.retries ?? [],+ retriesInfo: overallProgress.retries ?? [],outKey:outputFile && renderMetadata? getExpectedOutName(renderMetadata, bucketName, customCredentials).key@@ -300,8 +292,8 @@ export const getProgress = async ({estimatedBillingDurationInMilliseconds: priceFromBucket? priceFromBucket.estimatedBillingDurationInMilliseconds: null,- combinedFrames: overallProgress?.combinedFrames ?? 0,- timeToCombine: overallProgress?.timeToCombine ?? null,+ combinedFrames: overallProgress.combinedFrames ?? 0,+ timeToCombine: overallProgress.timeToCombine ?? null,type: 'success',};};