-
Notifications
You must be signed in to change notification settings - Fork 119
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
Any way to rescue the result of a bad redirection? #81
Comments
for the record, this is the return of curl for that url
|
Given Req follows redirects by default and curl does not, an equivalent curl invocation would be:
and it sensibly errors too. Since we got an exit from Finch, a standard Mix.install([
{:req, "~> 0.2.0"}
])
defmodule Test do
def run do
Req.get!("http://www.bugclipper.com")
catch :exit, reason ->
{:error, reason}
end
end
IO.inspect Test.run() In theory we could automatically catch exits from Finch but I'm not yet sure if that's a good idea. If anything, I'd like to wait to see more possible failure scenarios. |
FWIW the bug is not about Req or redirects, it's easy to reproduce it with just Finch: Mix.install([
{:finch, "~> 0.11.0"}
])
{:ok, _} = Finch.start_link(name: MyFinch)
Finch.build(:get, "http://") |> Finch.request(MyFinch) |> IO.inspect()
It looks like the exit doesn't originate in Finch, it comes either from NimblePool or more likely from Mint. The question still stands whether Req should handle exits, but in the meantime I think we can raise a better error from Finch. |
Closing in favour of sneako/finch#186. If the Finch team would like to move forward with improvements in this area, I'm sure they'd appreciate a PR. Thanks for the report @juanperi! |
Hey!! I was trying your library, and just found this in the wild.
A url returns a redirection to a bad place
Location: http://
I thought ok, I will just rescue all possible errors, and log them. But it doesn't work. It seems that this generates an exit that brings down the whole thing.
Do you know of any way of rescuing or stopping this kind of errors, so I can keep processing other records?
Example code:
The text was updated successfully, but these errors were encountered: