-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add compile-time flag to remove code for QUIC #2364
Add compile-time flag to remove code for QUIC #2364
Conversation
Using Invidious without QUIC has some issues |
Why this got closed? I know how to fix the issues. |
1c585d6
to
a5344cf
Compare
There we go, that should fix the gzip issues. However, in order to make Invidious fully functional without lsquic, we're going to need to replace the few dozen usages of |
src/invidious/helpers/utils.cr
Outdated
conn = QUIC::Client.new(url) | ||
else | ||
DB::Pool(ConnectonClientType).new(initial_pool_size: 0, max_pool_size: capacity, max_idle_pool_size: capacity, checkout_timeout: timeout) do | ||
conn = nil # Declare |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is actually required. The disable_quic
logic is considered a macro(?) so we can't actually access conn
unless we declare it outside first. You can try to build Invidious without this yourself, but it'll just result in a compile time error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whaaaa, even the inline version doesn't work!
conn = {% unless flag?(:disable_quic) %} use_quic ? QUIC::Client.new(url) : {% end %} HTTP::Client.new(url)
This is definitely an upstream bug...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works, though:
conn = (
{% unless flag?(:disable_quic) %}
CONFIG.use_quic ? QUIC::Client.new(url) : HTTP::Client.new(url)
{% else %}
HTTP::Client.new(url)
{% end %}
)
Blocked by #2364 (comment) |
Should be fixed. |
Running this PR causes the following to be outputted within the logs occasionally. Though, it doesn't seem to actually cause any noticeable effect.
Though Invidious doesn't seem to crash anymore, which is great! |
345d70f
to
4c0a8d9
Compare
For anyone that decides to test this PR in the future, could you please monitor the memory usage and crashes? I'm curious if this PR helps in any way, shape, or form on Invidious' general instability. |
Could you rebase? Thank you. |
4c0a8d9
to
f1f76d2
Compare
Done |
f1f76d2
to
abc957a
Compare
# and decompresses. However, explicitly applying it will remove this functionality. | ||
# | ||
# https://github.com/crystal-lang/crystal/issues/11252#issuecomment-929594741 | ||
{% unless flag?(:disable_quic) %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Check for the configuration option as well
end | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
end | |
else | |
end | |
else | |
{% end %} | |
# This can likely be optimized into a (small) pool sometime in the future. |
end | ||
{% else %} | ||
# This can likely be optimized into a (small) pool sometime in the future. | ||
HTTP::Client.get("https://yt3.ggpht.com#{url}") do |resp| | ||
return request_proc.call(resp) | ||
end | ||
{% end %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
end | |
{% else %} | |
# This can likely be optimized into a (small) pool sometime in the future. | |
HTTP::Client.get("https://yt3.ggpht.com#{url}") do |resp| | |
return request_proc.call(resp) | |
end | |
{% end %} | |
{% unless flag?(:disable_quic) %} | |
end | |
{% end %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This, and the above, avoid duplicate code (only the macro condition is duplicated)
request_proc = ->(response : HTTP::Client::Response) { | ||
env.response.status_code = response.status_code | ||
response.headers.each do |key, value| | ||
if !RESPONSE_HEADERS_BLACKLIST.includes?(key.downcase) | ||
env.response.headers[key] = value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this, and the code around (headers, response code check) is extremely similar between those three image proxy functions. This could be made into a separate function.
if CONFIG.use_quic | ||
if YT_POOL.client &.head(thumbnail_resource_path, headers).status_code == 200 | ||
name = thumb[:url] + ".jpg" | ||
break | ||
end | ||
else | ||
if HTTP::Client.head("https://i.ytimg.com#{thumbnail_resource_path}").status_code == 200 | ||
name = thumb[:url] + ".jpg" | ||
break | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering something: why isn't the if CONFIG.use_quic
check made at the YT_POOL
pool level, rather than here?
Continuation of b0f127d
abc957a
to
65fbdbf
Compare
Just added a commit to disable quic by default due to #2577. Once merged, assuming the user hasn't modified the |
For what is QUIC still used in the invidious code? |
QUIC shouldn't be used at all now when either To be absolutely certain of that, you can just go with the latter route and remove the dependency entirely from the libs folder. |
Regression from iv-org#2364
Regression from iv-org#2364
Regression from iv-org#2364
No description provided.