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

Support for turbo-rails 2.x gem #3661

Closed
ArturT opened this issue Dec 8, 2023 · 4 comments
Closed

Support for turbo-rails 2.x gem #3661

ArturT opened this issue Dec 8, 2023 · 4 comments

Comments

@ArturT
Copy link

ArturT commented Dec 8, 2023

Turbo 8 has been released in the turbo-rails gem 2.0.0.pre.beta.1.

Turbo 8 has a few cool features and I wanted to test this with the Rails app but the rails_admin depends on turbo-rails < 2 (see spec.add_dependency 'turbo-rails', '~> 1.0' in rails_admin.gemspec).

Reproduction steps

I updated the rails_admin.gemspec file to:

# rails_admin.gemspec
spec.add_dependency 'turbo-rails', ['>= 1.0', '< 3']

I was able to run the Rails app with rails_admin and the latest turbo-rails.
I'm using turbo-rails directly from github because they did some fix (the bug prevented to start my Rails app fix: hotwired/turbo-rails#523 ) that has not been released to rubygems yet.

# my rails app
# Gemfile
gem 'turbo-rails', github: 'hotwired/turbo-rails', ref: '4eb4e928e30be8cd537af8073f98b80ddea4a578'

Describe the bug

When it comes to rails_admin. While I'm using Turbo 8 (turbo-rails 2.x gem) I found an issue.
When I visit the http://localhost:3000/admin/user
In the search bar I type a user name and click on Refresh button then nothing happens. I get the error in the Chrome console:

RangeError: Maximum call stack size exceeded

Screenshot 2023-12-08 at 17 25 47
Screenshot 2023-12-08 at 17 25 59

Workaround

In order to keep using rails_admin and the latest turbo-rails 2.x I disabled Turbo in the rails_admin dashboard.

I added:

// app/assets/javascripts/rails_admin/custom/ui.js
window.Turbo.session.drive = false

Now I can search records in the rails_admin panel. I hope this workaround can be helpful for someone looking for a temporary solution to use both rails_admin and turbo-rails 2.x in your Rails app.

Expected behavior
rails_admin works with the turbo-rails 2.x gem.

Additional context

  • rails version: 7.0.8
  • rails_admin version: 3.1.2
  • rails_admin npm package version: not using
  • full stack trace (if there's an exception)
turbo.source.js:2557 RangeError: Maximum call stack size exceeded
    at uuid (turbo.source.js:363:1)
    at fetch (turbo.source.js:490:1)
    at fetch (turbo.source.js:493:1)
    at fetch (turbo.source.js:493:1)
    at fetch (turbo.source.js:493:1)
    at fetch (turbo.source.js:493:1)
    at fetch (turbo.source.js:493:1)
    at fetch (turbo.source.js:493:1)
    at fetch (turbo.source.js:493:1)
    at fetch (turbo.source.js:493:1)
formSubmissionErrored @ turbo.source.js:2557
requestErrored @ turbo.source.js:892
perform @ turbo.source.js:617
await in perform (async)
start @ turbo.source.js:825
submitForm @ turbo.source.js:2489
formSubmitted @ turbo.source.js:3913
submitBubbled @ turbo.source.js:1067

Let me know if there is something I could help to bring turbo-rails 2.x to rails_admin. Thanks.

@bb
Copy link
Contributor

bb commented Feb 5, 2024

I tried reproducing the above issue with shakapacker/webpack, but I had no issues (also tried searching my users).

I think it works for me because with npm packages, a package can have a different version than the main project when required as an indirect dependency. While my app uses turbo-rails 8.x (located directly in node_modules/@hotwired/), rails_admin uses version 7.x which is in node_modules/rails_admin/node_modules/@hotwired/)

The versions:

  • Rails 7.1.3
  • Gem rails_admin master (with turbo-rails version restriction changed)
  • NPM rails_admin 3.1.2 (which uses turbo-rails 7.1)
  • NPM @hotwired/turbo@^8.0.0-rc.2 and @hotwired/turbo-rails@^8.0.0-rc.2 directly installed

So, as long as you're using the client scripts via yarn/npm instead of the sprockets you should be fine.

@ArturT
Copy link
Author

ArturT commented Feb 5, 2024

I use the sprockets gem, the terser gem, and the importmap-rails gem.

@mshibuya
Copy link
Member

The originally reported issue seems to be fixed by hotwired/turbo#1077.

@ArturT
Copy link
Author

ArturT commented Feb 12, 2024

The originally reported issue seems to be fixed by hotwired/turbo#1077.

Yes. I confirm updating the turbo-rails gem fixes the issue. Thank you.

@ArturT ArturT closed this as completed Feb 12, 2024
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

3 participants