Skip to content
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

Fix for Faraday.new options #449

Closed

Conversation

stereobooster
Copy link

It expexts 1..2 parameters: def new(url = nil, options = nil)

@edtjones
Copy link
Collaborator

edtjones commented Jun 7, 2017

@zacharywelch you ok with this?

Copy link
Collaborator

@zacharywelch zacharywelch left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @stereobooster!

Before merging do you mind taking care of the spec?

@@ -21,10 +21,10 @@ class Bar; end
end

context "when setting custom options" do
before { subject.setup foo: { bar: "baz" }, url: "https://api.example.com" }
before { subject.setup foo: { bar: "baz" }, url: "https://api.example.com", timeout: 10, open_timeout: 2 }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Think we're already good on coverage here. timeout and open_timeout would probably distract from the spec which is focused on foo. Can we go ahead and remove this commit?

Copy link
Author

Choose a reason for hiding this comment

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

this test shows error - without fix it will fail

Copy link
Collaborator

Choose a reason for hiding this comment

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

So the build is passing on Travis w/ commit 86ceadd and to be sure I tested on a separate branch. We should be ok to drop commit 6f01adc 👍

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Believe there's confusion around the timeout and open_timeout options introduced in #400. These options should be part of the request hash set on the connection. There's a thread on Faraday w/ more detail.

As far as I can tell open_timeout and timeout are never recognized by Faraday unless they're part of the request hash, or set on the builder, going as far back as 0.5.7. The syntax should be

Her::API.setup(url: "https://api.example.com", request: { timeout: 10, open_timeout: 2 })

Can you confirm?

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, still haven't tested it. But found another connected bug: Net::HTTP retries idempotent requests once after a timeout, but its not configurable. So if we will fix this bug, and I will pass timeout, Net::HTTP will do two requests in case of Timeout. Nice.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Haven't played around w/ the faraday retry options much. Is there anything there you could take advantage of?

Regardless it sounds like this is a separate issue and there's another PR explaining how to properly use timeout and open_timeout w/ Her. I'll go ahead and close this PR then.

It expexts 1..2 parameters: def new(url = nil, options = nil)
@stereobooster
Copy link
Author

Test didn't fail for Travis, but failed for local env because Gemfiles used by two envs are different. We can change Gemfile to:

eval_gemfile(File.join(File.dirname(__FILE__), "gemfiles/Gemfile.activemodel-4.2"))

This way we will make sure that it is at least someway intersect.

@zacharywelch
Copy link
Collaborator

Going to close this for now but feel free to reopen if the suggestions in #452 are insufficient. Thanks!

@stereobooster stereobooster deleted the fix-for-faraday-options branch June 16, 2017 18:12
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.

None yet

3 participants