From 983109367ac7d3661a74fde402df752b9182f1dc Mon Sep 17 00:00:00 2001 From: Angel Caamal Date: Fri, 8 May 2026 19:18:33 +0000 Subject: [PATCH 1/2] fix(livestream): stop all channels before pool update to avoid FAILED_PRECONDITION --- media/livestream/test/livestream.test.js | 29 ++++++++++++------------ 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/media/livestream/test/livestream.test.js b/media/livestream/test/livestream.test.js index f574c351be..3dcfcced9a 100644 --- a/media/livestream/test/livestream.test.js +++ b/media/livestream/test/livestream.test.js @@ -53,21 +53,22 @@ before(async () => { parent: livestreamServiceClient.locationPath(projectId, location), }); for (const channel of channels) { - if (channel.createTime.seconds < DATE_NOW_SEC - THREE_HOURS_IN_SEC) { - const request = { - name: channel.name, - }; - try { - const [operation] = await livestreamServiceClient.stopChannel(request); - await operation.promise(); - } catch (err) { - //Ignore error when channel is not started. - console.log( - 'Existing channel already stopped. Ignore the following error.' - ); - console.log(err); - } + const request = { + name: channel.name, + }; + + try { + const [operation] = await livestreamServiceClient.stopChannel(request); + await operation.promise(); + } catch (err) { + //Ignore error when channel is not started. + console.log( + 'Existing channel already stopped. Ignore the following error.' + ); + console.log(err); + } + if (channel.createTime.seconds < DATE_NOW_SEC - THREE_HOURS_IN_SEC) { const [events] = await livestreamServiceClient.listEvents({ parent: channel.name, }); From 33d31efff4e1d6fa60556d254d9ebbfa5111f0b7 Mon Sep 17 00:00:00 2001 From: Angel Caamal Date: Fri, 8 May 2026 19:46:31 +0000 Subject: [PATCH 2/2] fix(livestream): scope channel cleanup to test prefix to avoid FAILED_PRECONDITION --- media/livestream/test/livestream.test.js | 50 +++++++++++++----------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/media/livestream/test/livestream.test.js b/media/livestream/test/livestream.test.js index 3dcfcced9a..4eefcdd13f 100644 --- a/media/livestream/test/livestream.test.js +++ b/media/livestream/test/livestream.test.js @@ -53,32 +53,36 @@ before(async () => { parent: livestreamServiceClient.locationPath(projectId, location), }); for (const channel of channels) { - const request = { - name: channel.name, - }; - - try { - const [operation] = await livestreamServiceClient.stopChannel(request); - await operation.promise(); - } catch (err) { - //Ignore error when channel is not started. - console.log( - 'Existing channel already stopped. Ignore the following error.' - ); - console.log(err); - } - - if (channel.createTime.seconds < DATE_NOW_SEC - THREE_HOURS_IN_SEC) { - const [events] = await livestreamServiceClient.listEvents({ - parent: channel.name, - }); + const isTestChannel = channel.name.includes( + 'nodejs-test-livestream-channel' + ); + if (isTestChannel) { + const request = { + name: channel.name, + }; + try { + const [operation] = await livestreamServiceClient.stopChannel(request); + await operation.promise(); + } catch (err) { + //Ignore error when channel is not started. + console.log( + 'Existing channel already stopped. Ignore the following error.' + ); + console.log(err); + } - for (const event of events) { - await livestreamServiceClient.deleteEvent({ - name: event.name, + if (channel.createTime.seconds < DATE_NOW_SEC - THREE_HOURS_IN_SEC) { + const [events] = await livestreamServiceClient.listEvents({ + parent: channel.name, }); + + for (const event of events) { + await livestreamServiceClient.deleteEvent({ + name: event.name, + }); + } + await livestreamServiceClient.deleteChannel(request); } - await livestreamServiceClient.deleteChannel(request); } }