Skip to content

🎥 Make videos programmatically with React

fix time shifting

Jonny Burger271e3aeb1115
diff --git a/packages/lambda/src/functions/helpers/calculate-price-from-bucket.ts b/packages/lambda/src/functions/helpers/calculate-price-from-bucket.ts
index e55d9a9357..a76e6ba703 100644
--- a/packages/lambda/src/functions/helpers/calculate-price-from-bucket.ts
+++ b/packages/lambda/src/functions/helpers/calculate-price-from-bucket.ts
@@ -41,7 +41,7 @@ export const estimatePriceFromBucket = ({
const elapsedTime =
timeToFinish === null
- ? Date.now() - (renderMetadata?.startedDate ?? 0)
+ ? Math.max(0, Date.now() - (renderMetadata?.startedDate ?? 0))
: timeToFinish;
const unfinished = Math.max(
@@ -67,14 +67,12 @@ export const estimatePriceFromBucket = ({
const accruedSoFar = Number(
estimatePrice({
region: getCurrentRegionInFunction(),
- durationInMiliseconds: Math.max(
- 0,
+ durationInMiliseconds:
calculateChunkTimes({
contents,
renderId: renderMetadata.renderId,
type: 'combined-time-for-cost-calculation',
- }) + timeElapsedOfUnfinished
- ),
+ }) + timeElapsedOfUnfinished,
memorySizeInMb,
}).toPrecision(5)
);