From 4e98d843da15e635aca14e9a146ffb2cd156e93c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 19 Mar 2024 09:26:40 +0100 Subject: [PATCH] Success on update "not in processing state" error Or the job is never "ended" --- .../src/server/process/shared/process-live.ts | 3 +++ .../src/peertube-runner/live-transcoding.ts | 21 ++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/apps/peertube-runner/src/server/process/shared/process-live.ts b/apps/peertube-runner/src/server/process/shared/process-live.ts index 421803dc1..d6c7f8f12 100644 --- a/apps/peertube-runner/src/server/process/shared/process-live.ts +++ b/apps/peertube-runner/src/server/process/shared/process-live.ts @@ -152,6 +152,9 @@ export class ProcessLiveRTMPHLSTranscoding { if (type === ServerErrorCode.RUNNER_JOB_NOT_IN_PROCESSING_STATE) { logger.info('Stopping transcoding as the job is not in processing state anymore') + this.sendSuccess() + .catch(err => logger.error({ err }, 'Cannot send success')) + res() } else { logger.error({ err }, 'Cannot send update after added/deleted chunk, stopping live transcoding') diff --git a/packages/tests/src/peertube-runner/live-transcoding.ts b/packages/tests/src/peertube-runner/live-transcoding.ts index 9351bc5e2..85eac4ce9 100644 --- a/packages/tests/src/peertube-runner/live-transcoding.ts +++ b/packages/tests/src/peertube-runner/live-transcoding.ts @@ -1,16 +1,15 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { expect } from 'chai' import { wait } from '@peertube/peertube-core-utils' -import { HttpStatusCode, VideoPrivacy } from '@peertube/peertube-models' +import { HttpStatusCode, RunnerJobState, VideoPrivacy } from '@peertube/peertube-models' import { areMockObjectStorageTestsDisabled } from '@peertube/peertube-node-utils' import { + ObjectStorageCommand, + PeerTubeServer, cleanupTests, createMultipleServers, doubleFollow, findExternalSavedVideo, makeRawRequest, - ObjectStorageCommand, - PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel, stopFfmpeg, @@ -23,6 +22,7 @@ import { checkPeerTubeRunnerCacheIsEmpty } from '@tests/shared/directories.js' import { testLiveVideoResolutions } from '@tests/shared/live.js' import { PeerTubeRunnerProcess } from '@tests/shared/peertube-runner-process.js' import { SQLCommand } from '@tests/shared/sql-command.js' +import { expect } from 'chai' describe('Test Live transcoding in peertube-runner program', function () { let servers: PeerTubeServer[] = [] @@ -54,8 +54,19 @@ describe('Test Live transcoding in peertube-runner program', function () { }) await stopFfmpeg(ffmpegCommand) - await waitUntilLiveWaitingOnAllServers(servers, video.uuid) + + const { data } = await servers[0].runnerJobs.list({ sort: '-createdAt' }) + + while (true) { + const liveJob = data.find(d => d.type === 'live-rtmp-hls-transcoding') + expect(liveJob).to.exist + + if (liveJob.state.id === RunnerJobState.COMPLETED) break + + await wait(500) + } + await servers[0].videos.remove({ id: video.id }) })