2
votes

I am going to a URL endpoint that is rendering a JSON response, yet I see this error in my rails server logs:

Started GET "/sw.js" for ::1 at 2019-07-08 22:39:43 +0530

ActionController::RoutingError (No route matches [GET] "/sw.js"):

actionpack (5.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:65:in 'call'
web-console (3.7.0) lib/web_console/middleware.rb:135:in 'call_app'
web-console (3.7.0) lib/web_console/middleware.rb:30:in 'block in call'
web-console (3.7.0) lib/web_console/middleware.rb:20:in 'catch'
web-console (3.7.0) lib/web_console/middleware.rb:20:in 'call'
actionpack (5.2.3) lib/action_dispatch/middleware/show_exceptions.rb:33:in 'call'
railties (5.2.3) lib/rails/rack/logger.rb:38:in 'call_app'
railties (5.2.3) lib/rails/rack/logger.rb:26:in 'block in call'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in 'block in tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:28:in 'tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in 'tagged'
railties (5.2.3) lib/rails/rack/logger.rb:26:in 'call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in 'call'
actionpack (5.2.3) lib/action_dispatch/middleware/remote_ip.rb:81:in 'call'
actionpack (5.2.3) 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 (5.2.3) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in 'call'
actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in 'call' actionpack (5.2.3) lib/action_dispatch/middleware/static.rb:127:in 'call'
rack (2.0.7) lib/rack/sendfile.rb:111:in 'call'
railties (5.2.3) lib/rails/engine.rb:524: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'
Started GET "/search_stocks?utf8=%E2%9C%93&stock=GOOG&button=" for ::1 at 2019-07-08 22:39:48 +0530
Processing by StocksController#search as JS
Parameters: {"utf8"=>"✓", "stock"=>"GOOG", "button"=>""}
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ? [["id", 2], ["LIMIT", 1]]
↳ /Users/bhanugupta/.rvm/gems/ruby-2.6.3@name/gems/activerecord-5.2.3/lib/active_record/log_subscriber.rb:98
Rendered users/_result.html.erb (0.9ms)
Rendered users/_result.js.erb (3.3ms)
Completed 200 OK in 15056ms (Views: 5.8ms | ActiveRecord: 0.2ms)

Where exactly could this be coming from?

I created a new rails 5.x app yesterday, and I am not sure where this file is being referenced from.

I don't even have a layout for this controller either.

rake routes:

api_boards                GET  /api/boards(.:format)                                                                    api/boards#index
api_board                 GET  /api/boards/:id(.:format)                                                                api/boards#show
rails_service_blob        GET  /rails/active_storage/blobs/:signed_id/*filename(.:format)                               active_storage/blobs#show
rails_blob_representation GET  /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show
rails_disk_service        GET  /rails/active_storage/disk/:encoded_key/*filename(.:format)                              active_storage/disk#show
update_rails_disk_service PUT  /rails/active_storage/disk/:encoded_token(.:format)                                      active_storage/disk#update
rails_direct_uploads      POST /rails/active_storage/direct_uploads(.:format)                                           active_storage/direct_uploads#create
2

2 Answers

4
votes

Service worker registrations persist across browser restarts, and it's unfortunately common to have an older registration retain control of a common localhost:port combination that's then reused for a different project.

You can unregister the current service worker controlling a page by running

navigator.serviceWorker.getRegistration().then(r => r.unregister())

in the JavaScript console of Chrome's DevTools.

You can see a list of all service worker registrations and unregister them manually in the Applications panel of Chrome's DevTools, after clicking on the "Show all" button if needed.

reference

2
votes

FWIW I get this with every Rail 6.0.0 app I create. Not worked it out yet either.