From 85b99349ad3c95efc7640c0d33a6198d53256d4f Mon Sep 17 00:00:00 2001 From: Fijxu Date: Mon, 21 Jul 2025 14:37:04 -0400 Subject: [PATCH] fix: select a random companion if there is no working ends --- src/invidious/routes/before_all.cr | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/invidious/routes/before_all.cr b/src/invidious/routes/before_all.cr index 474917c7..8d899fa1 100644 --- a/src/invidious/routes/before_all.cr +++ b/src/invidious/routes/before_all.cr @@ -54,7 +54,11 @@ module Invidious::Routes::BeforeAll current_companion = env.request.cookies[CONFIG.server_id_cookie_name].value.try &.to_i rescue working_ends = BackendInfo.get_working_ends - current_companion = working_ends.sample + if !working_ends.empty? + current_companion = working_ends.sample + else + current_companion = rand(CONFIG.invidious_companion.size) + end end if current_companion > CONFIG.invidious_companion.size