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

Stack level too deep #40781

Closed
fynsta opened this issue Dec 10, 2020 · 8 comments
Closed

Stack level too deep #40781

fynsta opened this issue Dec 10, 2020 · 8 comments

Comments

@fynsta
Copy link

fynsta commented Dec 10, 2020

I installed Rails 6.1 today, but I got the error "Stack level too deep" with the following stack trace

        - activesupport (6.1.0) lib/active_support/core_ext/object/json.rb:173:in `each'
        - activesupport (6.1.0) lib/active_support/core_ext/object/json.rb:173:in `as_json'
        - activesupport (6.1.0) lib/active_support/core_ext/object/json.rb:57:in `as_json'
        - activesupport (6.1.0) lib/active_support/core_ext/object/json.rb:174:in `block in as_json'
        - activesupport (6.1.0) lib/active_support/core_ext/object/json.rb:173:in `each'
        - activesupport (6.1.0) lib/active_support/core_ext/object/json.rb:173:in `as_json'
        - activesupport (6.1.0) lib/active_support/core_ext/object/json.rb:57:in `as_json'
        - activesupport (6.1.0) lib/active_support/core_ext/object/json.rb:174:in `block in as_json'
        - activesupport (6.1.0) lib/active_support/core_ext/object/json.rb:173:in `each'
        - activesupport (6.1.0) lib/active_support/core_ext/object/json.rb:173:in `as_json'
        - activesupport (6.1.0) lib/active_support/core_ext/object/json.rb:57:in `as_json'

and so forth. This looks like a rails issue to me because it seems like some kind of recursive call stack.

System configuration

Rails version:
Rails 6.1.0

Ruby version:
ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin19]

@composerinteralia
Copy link
Member

Could you provide a reproduction script or a sample application to reproduce the bug?

One way you might run into this error is if you try to turn an object that references itself into json:

x = {}
x[:x] = x
x.to_json

That would not be a Rails bug, but I think it would produce a stack trace like the one you show here.

@fynsta
Copy link
Author

fynsta commented Dec 10, 2020

I see, thanks for the feedback!
I'll try to find the root of the problem. Is this something that might not have occurred in 6.0?

@MatheusSilvaSouza
Copy link

MatheusSilvaSouza commented Dec 10, 2020

I also have that problem on Rails 5.2.4.4
It seems to be caused by a recursive call to as_json in activesupport-5.2.4.4/lib/active_support/core_ext/object/json.rb:174

@paulwis
Copy link

paulwis commented Dec 10, 2020

In my case, removing the meta_request gem solved this in 6.1.

@jeffblake
Copy link

In my case I was using a custom Logger formatter that called to_json at the end. Changed it to JSON.dump(hash) to fix it

@fynsta
Copy link
Author

fynsta commented Dec 11, 2020

In my case, removing the meta_request gem solved this in 6.1.

That actually seems to have done the trick in my case. Thanks!

Closing the issue as it does not seem to be Rails' fault.

@zzemla
Copy link

zzemla commented Mar 12, 2021

For anyone looking for a solution:
dejan/rails_panel#177 (comment)

MuhammetDilmac pushed a commit to rubytr/ruby-tr that referenced this issue Apr 2, 2021
* upgrade rails version to rails 6.1.3.1 and ruby version to 2.6.6

* make changes to the files after running rails app:update

* fix small problems on db/schema.rb file

* fix rubocop error

* update contributing documentation to include necessary commands

* remove meta_request gem, because it is not compatible with rails 6.1.x

See rails/rails#40781
and
dejan/rails_panel#177 (comment)
for more details

* change cookies serializer to hybrid to not break existing cookies

For more details:
https://bigbinary.com/blog/migrating-existing-session-cookies-while-upgrading-to-rails-4-1-and-above

* change ruby versions in workflow and .ruby-version file

* add ruby installation step to contributing.md file

* drop old index name for active admin comments

This will be helpful to the developers who had the database and run
migrations in the past. It will basically remove the index with the old
name and it will create the index with the new name.

* rename old index name, instead of dropping it and creating new one
MuhammetDilmac pushed a commit to rubytr/ruby-tr that referenced this issue Apr 2, 2021
* upgrade rails version to rails 6.1.3.1 and ruby version to 2.6.6

* make changes to the files after running rails app:update

* fix small problems on db/schema.rb file

* fix rubocop error

* update contributing documentation to include necessary commands

* remove meta_request gem, because it is not compatible with rails 6.1.x

See rails/rails#40781
and
dejan/rails_panel#177 (comment)
for more details

* change cookies serializer to hybrid to not break existing cookies

For more details:
https://bigbinary.com/blog/migrating-existing-session-cookies-while-upgrading-to-rails-4-1-and-above

* change ruby versions in workflow and .ruby-version file

* add ruby installation step to contributing.md file

* drop old index name for active admin comments

This will be helpful to the developers who had the database and run
migrations in the past. It will basically remove the index with the old
name and it will create the index with the new name.

* rename old index name, instead of dropping it and creating new one

* update pg gem to v1.2.3
@leompeters
Copy link

Thank you, @zzemla. You rock!

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

No branches or pull requests

7 participants