Skip to content

Invidious is an alternative front-end to YouTube

Remove invalid connections from pool

Omar Roth7f8746fcd481
diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr
index d0076024..2e802051 100644
--- a/src/invidious/helpers/utils.cr
+++ b/src/invidious/helpers/utils.cr
@@ -1607,9 +1607,17 @@ struct HTTPPool
end
end
- response = yield conn
- conn.unset_proxy
- response
+ begin
+ response = yield conn
+ conn.unset_proxy
+ response
+ rescue ex
+ conn = HTTPClient.new(url)
+ conn.family = (url.host == "www.youtube.com") ? CONFIG.force_resolve : Socket::Family::UNSPEC
+ conn.read_timeout = 5.seconds
+ conn.connect_timeout = 5.seconds
+ yield conn
+ end
end
end