Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/reverse_proxy_plug/http_client/adapters/req.ex
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,20 @@ if Code.ensure_loaded?(Req) do
end

defp async_request(req, parent) do
connect_timeout =
req.options
|> Keyword.get(:connect_options, [])
|> Keyword.get(:timeout, 30_000)

recv_timeout = Keyword.get(req.options, :recv_timeout, 15_000)
Copy link
Contributor

@stocks29 stocks29 Mar 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the option for req is :receive_timeout not :recv_timeout

https://hexdocs.pm/req/Req.html#new/1

Suggested change
recv_timeout = Keyword.get(req.options, :recv_timeout, 15_000)
recv_timeout = Keyword.get(req.options, :receive_timeout, 15_000)


fn ->
ret = request(req)
send(parent, :eof)
ret
end
|> Task.async()
|> Task.await()
|> Task.await(connect_timeout + recv_timeout)
Copy link
Contributor

@stocks29 stocks29 Mar 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do wonder if the timeout here should just be :infinity and let Req timeout and respond instead.

Also worth considering... why even run this in a task if we're immediately await()ing it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put up another PR which removes the Task completely since it doesn't appear to serve any purpose:

#239

end

defp body_stream do
Expand Down