activerecord-import: Using activerecord-import with Rails 6.1.0.rc1 results in SystemStackError: stack level too deep

Using activerecord-import with Rails 6.1.0.rc1 results in SystemStackError: stack level too deep any time we attempt to establish our own connection.

The line in question is:

activerecord-import-1.0.7/lib/activerecord-import/import.rb:250:in `establish_connection'

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 22 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Whew man, I’m glad you were able to get to the bottom of this one. I feel bad this negatively impacted your tests. I wonder if mocking libraries are working on this issue with prepended modules?

@codeodor after finally doing some research into this, I think I discovered the root cause of the issue. It seems like your code or another gem in your project is using alias_method on AR::Base#establish_connection. Can you confirm if this is happening?

See:

Hey, to clarify: I didn’t have an issue directly with an attempted import. I didn’t even try it. The problem was that AR::Import code was causing my app to have this error when I made my own calls to AR::Base#establish_connection.

I’m gonna try to give an example app later this week, but I am a little swamped so I apologize in advance for the delay.

What’s weird is the PR that introduced the prepend was fixing a stack level too deep error: https://github.com/zdennis/activerecord-import/issues/647 😅

Hey thanks for all digging into this! I’ll have to see look this over a little bit, but I think your proposed solution seems very reasonable 👍