Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix: grant completed source reuploads a fresh generation

Richie McIlroy284ae24a79bd
diff --git a/apps/web/__tests__/unit/desktop-recording-jobs.test.ts b/apps/web/__tests__/unit/desktop-recording-jobs.test.ts
index 2d02499ff..0d596a369 100644
--- a/apps/web/__tests__/unit/desktop-recording-jobs.test.ts
+++ b/apps/web/__tests__/unit/desktop-recording-jobs.test.ts
@@ -895,6 +895,51 @@ describe("retained-source retry policy", () => {
});
describe("recovery admission", () => {
+ it.each([null, source])(
+ "gives a verified re-upload fresh attempts without reviving the old worker: %j",
+ async (retainedSource) => {
+ const old = await createAttempt();
+ rows.jobs = [
+ {
+ ...old,
+ state: "source-blocked",
+ source: retainedSource,
+ attemptCount: 70,
+ leaseExpiresAt: null,
+ errorCode: "source-reupload-required",
+ },
+ ];
+ const resumed = await ensureSegmentProcessingJob({
+ videoId,
+ userId,
+ verification: { ...verification, requiredAudio: false },
+ });
+ expect(resumed.created).toBe(true);
+ expect(resumed.job.generation).not.toBe(old.generation);
+ expect(resumed.job).toMatchObject({
+ state: "committing",
+ attemptCount: 0,
+ source: null,
+ verification: { requiredAudio: true },
+ });
+ expect(await heartbeatAttempt(old)).toBe(false);
+ expect(
+ await claimProcessingAttempt({
+ videoId,
+ generation: resumed.job.generation,
+ }),
+ ).toMatchObject({ attemptCount: 1 });
+ const repeated = await ensureSegmentProcessingJob({
+ videoId,
+ userId,
+ verification,
+ });
+ expect(repeated.created).toBe(false);
+ expect(repeated.job.generation).toBe(resumed.job.generation);
+ expect(repeated.job.attemptCount).toBe(1);
+ },
+ );
+
it("keeps an inspected missing source paused until a completion request resumes it", async () => {
const attempt = await createAttempt();
const paused = {
diff --git a/apps/web/lib/desktop-recording-jobs.ts b/apps/web/lib/desktop-recording-jobs.ts
index 7d2676e87..b0228443f 100644
--- a/apps/web/lib/desktop-recording-jobs.ts
+++ b/apps/web/lib/desktop-recording-jobs.ts
@@ -290,9 +290,24 @@ export async function ensureSegmentProcessingJob({
verification !== undefined &&
(job.source !== null || job.verification !== null) &&
!sameArtifact(verification, job);
- if (created || replacesArtifact) {
- if (replacesArtifact) {
- job = candidate;
+ const resumesReupload =
+ verification !== undefined &&
+ job.errorCode === DESKTOP_RECORDING_SOURCE_REUPLOAD_REQUIRED;
+ if (created || replacesArtifact || resumesReupload) {
+ if (replacesArtifact || resumesReupload) {
+ job =
+ resumesReupload && !replacesArtifact && verification
+ ? {
+ ...candidate,
+ verification: {
+ ...verification,
+ requiredAudio:
+ verification.requiredAudio ||
+ job.verification?.requiredAudio === true ||
+ job.source?.requiredAudio === true,
+ },
+ }
+ : candidate;
await tx
.update(videoProcessingJobs)
.set(job)