Skip to content

Conversation

mwhitworth
Copy link
Collaborator

fixes #236

respecting these timeout values means we can keep the task timeout and the actual request timeouts in line

|> 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)

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

@mwhitworth mwhitworth force-pushed the req-respect-timeouts branch from a5a2980 to e50b012 Compare April 11, 2025 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Req Adapter: Task max timeout fixed at 5 sec
2 participants