socketry / async-http

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stack level too deep (SystemStackError) then raise exception in Sync. Then try to show warn in console

znppaed7 opened this issue · comments

Example:

    def example
      Sync do
        response = @internet.get('https://example.com')
        raise 'exception'
        [response.success?, response.status, response.read]
      end
    end

Result: ruby-3.2.1/gems/activesupport-7.0.4.2/lib/active_support/core_ext/object/instance_variables.rb:15:in `map': stack level too deep (SystemStackError)

Problem code:

in file console/terminal/logger.rb

def format_options(options, output)
  format_value(options.to_json, output)
end

The data Async::HTTP::Protocol::HTTP1::Client in the options field contains cyclic references. The to_json method is overridden in the active_support/core_ext/object/json.rb file.

class Object
  def as_json(options = nil) # :nodoc:
    if respond_to?(:to_hash)
      to_hash.as_json(options)
    else
      instance_values.as_json(options)
    end
  end
end

This method does not know how to resolve cyclic references.
This problem exists only in the rails framework. There is no problem without rails framework.

I have no suggestion on how to solve this problem...

I believe this is a bug with Rails. Let me take a look.

I believe this can be fixed by the latest release of protocol-http.

Basically, Rails forced us to implement as_json.

There was a minor follow up: socketry/protocol-http#54