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 infinite recursion and NameError on load when running with -rdebug #1203

Closed
wants to merge 2 commits into from
Closed
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
11 changes: 11 additions & 0 deletions lib/faraday.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ def respond_to_missing?(symbol, include_private = false)
# Internal: Proxies method calls on the Faraday constant to
# .default_connection.
def method_missing(name, *args, &block)
# When running under debugger with a breakpoint set,
# self.to_str is called repeatedly during module load,
# including the time before the default_connection getter below is loaded
return nil if name == :default_connection

if default_connection.respond_to?(name)
default_connection.send(name, *args, &block)
else
Expand All @@ -135,6 +140,12 @@ def method_missing(name, *args, &block)
# access the Faraday constant directly, such as
# <code>Faraday.get "https://faraday.com"</code>.
def self.default_connection
# When running under debugger with a breakpoint set,
# self.to_str is called repeatedly during module load,
# including the time after this getter is loaded but
# before the libs delay-loading below fires
return nil unless const_defined?(:Connection)

@default_connection ||= Connection.new(default_connection_options)
end

Expand Down