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

FrozenError can't modify frozen Array (Rails 6.0 with zeitwerk autoloader) #52

Closed
sho918 opened this issue Sep 10, 2019 · 7 comments
Closed
Assignees
Labels

Comments

@sho918
Copy link

sho918 commented Sep 10, 2019

Custom exceptions app not working with zeitwerk autoloader.
Works well with classic autoloader (config.autoloader = :classic).

env

  • Ruby 2.6.4
  • Rails 6.0.0
  • Rambulance 1.0.2

log

Started GET "/rambulance/not_found" for 127.0.0.1 at 2019-09-10 14:00:57 +0900
   (0.7ms)  SELECT sqlite_version(*)
  
FrozenError (can't modify frozen Array):
  
activesupport (6.0.0) lib/active_support/dependencies.rb:514:in `concat'
activesupport (6.0.0) lib/active_support/dependencies.rb:514:in `load_file'
activesupport (6.0.0) lib/active_support/dependencies.rb:407:in `block in require_or_load'
activesupport (6.0.0) lib/active_support/dependencies.rb:40:in `block in load_interlock'
activesupport (6.0.0) lib/active_support/dependencies/interlock.rb:14:in `block in loading'
activesupport (6.0.0) lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
activesupport (6.0.0) lib/active_support/dependencies/interlock.rb:13:in `loading'
activesupport (6.0.0) lib/active_support/dependencies.rb:40:in `load_interlock'
activesupport (6.0.0) lib/active_support/dependencies.rb:390:in `require_or_load'
bootsnap (1.4.5) lib/bootsnap/load_path_cache/core_ext/active_support.rb:48:in `block in require_or_load'
bootsnap (1.4.5) lib/bootsnap/load_path_cache/core_ext/active_support.rb:16:in `allow_bootsnap_retry'
bootsnap (1.4.5) lib/bootsnap/load_path_cache/core_ext/active_support.rb:47:in `require_or_load'
activesupport (6.0.0) lib/active_support/dependencies.rb:545:in `load_missing_constant'
bootsnap (1.4.5) lib/bootsnap/load_path_cache/core_ext/active_support.rb:60:in `block in load_missing_constant'
bootsnap (1.4.5) lib/bootsnap/load_path_cache/core_ext/active_support.rb:16:in `allow_bootsnap_retry'
bootsnap (1.4.5) lib/bootsnap/load_path_cache/core_ext/active_support.rb:59:in `load_missing_constant'
rambulance (1.0.2) lib/rambulance/railtie.rb:10:in `block (2 levels) in <class:Railtie>'
actionpack (6.0.0) lib/action_dispatch/routing/mapper.rb:19:in `block in <class:Constraints>'
actionpack (6.0.0) lib/action_dispatch/routing/mapper.rb:48:in `serve'
actionpack (6.0.0) lib/action_dispatch/journey/router.rb:49:in `block in serve'
actionpack (6.0.0) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.0.0) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.0.0) lib/action_dispatch/routing/route_set.rb:837:in `call'
rack (2.0.7) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.0.7) lib/rack/etag.rb:25:in `call'
rack (2.0.7) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.7) lib/rack/head.rb:12:in `call'
actionpack (6.0.0) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.0.7) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.7) lib/rack/session/abstract/id.rb:226:in `call'
actionpack (6.0.0) lib/action_dispatch/middleware/cookies.rb:648:in `call'
activerecord (6.0.0) lib/active_record/migration.rb:567:in `call'
actionpack (6.0.0) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.0.0) lib/active_support/callbacks.rb:101:in `run_callbacks'
actionpack (6.0.0) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.0.0) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.0) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call'
actionpack (6.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
web-console (4.0.1) lib/web_console/middleware.rb:132:in `call_app'
web-console (4.0.1) lib/web_console/middleware.rb:28:in `block in call'
web-console (4.0.1) lib/web_console/middleware.rb:17:in `catch'
web-console (4.0.1) lib/web_console/middleware.rb:17:in `call'
actionpack (6.0.0) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.0.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (6.0.0) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.0.0) lib/active_support/tagged_logging.rb:80:in `block in tagged'
activesupport (6.0.0) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (6.0.0) lib/active_support/tagged_logging.rb:80:in `tagged'
railties (6.0.0) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (6.0.0) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (6.0.0) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.0.7) lib/rack/method_override.rb:22:in `call'
rack (2.0.7) lib/rack/runtime.rb:22:in `call'
activesupport (6.0.0) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.0.0) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.0) lib/action_dispatch/middleware/static.rb:126:in `call'
rack (2.0.7) lib/rack/sendfile.rb:111:in `call'
actionpack (6.0.0) lib/action_dispatch/middleware/host_authorization.rb:83:in `call'
webpacker (4.0.7) lib/webpacker/dev_server_proxy.rb:29:in `perform_request'
rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call'
railties (6.0.0) lib/rails/engine.rb:526:in `call'
puma (3.12.1) lib/puma/configuration.rb:227:in `call'
puma (3.12.1) lib/puma/server.rb:660:in `handle_request'
puma (3.12.1) lib/puma/server.rb:474:in `process_client'
puma (3.12.1) lib/puma/server.rb:334:in `block in run'
puma (3.12.1) lib/puma/thread_pool.rb:135:in `block in spawn_thread'
@yuki24 yuki24 self-assigned this Sep 29, 2019
@yuki24 yuki24 added the bug label Sep 29, 2019
@yuki24
Copy link
Owner

yuki24 commented Sep 29, 2019

Hi @sho918, thanks for reporting. I just quickly looked into this issue but it seems like the AcitonDispatch::IntegrationTest has a foundational change and I couldn't run the test at all. So this is going to take a little more time unless someone else pokes around it.

@yuki24
Copy link
Owner

yuki24 commented Sep 29, 2019

I couldn't replicate the issue with a fresh Rails app:

$ ruby -v
ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-darwin18]
$ rails -v
Rails 6.0.0

$ rails new rambulance-test && cd rambulance-test
$ rails webpacker:install
$ bundle add ranbulance
$ rails g rambulance:install
$ rails s &
$ sleep 5 # wait for Rails to spin up
$ open http://localhost:3000/rambulance/not_found

I'm not sure what's going on there, but you may need to purge bootsnap cache when switching.

@yuki24 yuki24 added help wanted and removed bug labels Sep 29, 2019
@sho918
Copy link
Author

sho918 commented Sep 30, 2019

Thanks for response.
It works well without Custom Exceptions App (or Zeitwerk).

But an error occurs when combination of Custom Exceptions App and Zeitwerk autoloader.

$ rails new rambulance-test
$ cd rambulance-test
$ bundle add rambulance
$ rails g rambulance:install
$ rails s
$ open http://localhost:3000/rambulance/not_found # Works fine

# Install Custom Exceptions App
$ rails g rambulance:exceptions_app

# with Zeitwerk autoloader
$ rails r "puts Rails.autoloaders.zeitwerk_enabled?"
=> true
$ rails s
$ open http://localhost:3000/rambulance/not_found # FrozenError (can't modify frozen Array)

# without Zeitwerk autoloader (`config.autoloader = :classic`)
$ rails r "puts Rails.autoloaders.zeitwerk_enabled?"
=> false
$ rails s
$ open http://localhost:3000/rambulance/not_found # Works fine

@yuki24 yuki24 added bug and removed help wanted labels Sep 30, 2019
@yuki24
Copy link
Owner

yuki24 commented Sep 30, 2019

Confirmed this bug. I'll look into it. Thanks for reporting.

@yuki24 yuki24 closed this as completed in d5a683b Oct 1, 2019
@yuki24
Copy link
Owner

yuki24 commented Oct 1, 2019

I was able to replicate this bug in an actual rails app, but not in the test. I pushed the fix, but it would be great if you could confirm the fix on your side too. I will cut a new release once it's confirmed.

@sho918
Copy link
Author

sho918 commented Oct 1, 2019

Thank you for quick fix.
It working without any problems on my rails app.

@yuki24
Copy link
Owner

yuki24 commented Oct 3, 2019

released as part of v1.0.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants