Skip to content

Commit c965936

Browse files
committed
fix: preserve upload headroom in processing budgets
1 parent aaadf58 commit c965936

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

apps/web/__tests__/unit/desktop-recording-jobs.test.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ const verification: RecordingVerification = {
9090
let rows: Record<string, Row[]>;
9191
let lockingOperations: string[];
9292

93+
function getJobRow(): Row {
94+
const job = rows.jobs?.[0];
95+
if (!job) throw new Error("Missing job fixture");
96+
return job;
97+
}
98+
9399
function matches(row: Row, condition?: Condition): boolean {
94100
if (!condition) return true;
95101
if (condition.op === "and")
@@ -723,31 +729,31 @@ describe("retained-source retry policy", () => {
723729
it("pauses a repeatedly failing recording and retains its source", async () => {
724730
const attempt = await createAttempt();
725731
await persistCommittedSource(attempt, source);
726-
Object.assign(rows.jobs[0], { attemptCount: 5 });
732+
Object.assign(getJobRow(), { attemptCount: 5 });
727733
expect(
728734
await scheduleRetry({
729735
...attempt,
730736
errorCode: "output-invalid",
731737
errorMessage: "Timeline mismatch",
732738
}),
733739
).toBe(true);
734-
expect(rows.jobs[0]).toMatchObject({
740+
expect(rows.jobs?.[0]).toMatchObject({
735741
state: "source-blocked",
736742
source,
737743
errorCode: "processing-retry-exhausted",
738744
errorMessage: "output-invalid: Timeline mismatch",
739745
});
740-
expect(rows.uploads[0]).toMatchObject({ phase: "error" });
746+
expect(rows.uploads?.[0]).toMatchObject({ phase: "error" });
741747
vi.setSystemTime(new Date(now.getTime() + 24 * 60 * 60_000));
742748
expect(
743749
await claimProcessingAttempt({ videoId, generation: attempt.generation }),
744750
).toBeNull();
745-
expect(rows.jobs[0]?.attemptCount).toBe(5);
751+
expect(rows.jobs?.[0]?.attemptCount).toBe(5);
746752
});
747753

748754
it("pauses an exhausted legacy job before downloading its source again", async () => {
749755
const attempt = await createAttempt();
750-
Object.assign(rows.jobs[0], {
756+
Object.assign(getJobRow(), {
751757
attemptCount: 220,
752758
state: "retry",
753759
leaseExpiresAt: null,
@@ -756,24 +762,24 @@ describe("retained-source retry policy", () => {
756762
expect(
757763
await claimProcessingAttempt({ videoId, generation: attempt.generation }),
758764
).toBeNull();
759-
expect(rows.jobs[0]).toMatchObject({
765+
expect(rows.jobs?.[0]).toMatchObject({
760766
attemptCount: 220,
761767
errorCode: "processing-retry-exhausted",
762768
});
763769
await ensureSegmentProcessingJob({ videoId, userId });
764-
expect(rows.jobs[0]).toMatchObject({
770+
expect(rows.jobs?.[0]).toMatchObject({
765771
state: "source-blocked",
766772
errorCode: "processing-retry-exhausted",
767773
});
768774
});
769775

770776
it("does not interrupt an active final attempt", async () => {
771777
const attempt = await createAttempt();
772-
Object.assign(rows.jobs[0], { attemptCount: 5 });
778+
Object.assign(getJobRow(), { attemptCount: 5 });
773779
expect(
774780
await claimProcessingAttempt({ videoId, generation: attempt.generation }),
775781
).toBeNull();
776-
expect(rows.jobs[0]).toMatchObject({
782+
expect(rows.jobs?.[0]).toMatchObject({
777783
state: "committing",
778784
attemptId: attempt.attemptId,
779785
});

apps/web/lib/media-processing-budget.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export async function reserveMediaProcessingBudget(input: {
3939
input.sourceBytes,
4040
);
4141
const configured = Number(
42-
process.env.MEDIA_PROCESSING_DAILY_BUDGET_GIB ?? "100",
42+
process.env.MEDIA_PROCESSING_DAILY_BUDGET_GIB ?? "512",
4343
);
4444
if (
4545
!Number.isFinite(configured) ||

0 commit comments

Comments
 (0)