Closed randall-coding closed 1 year ago
Did you ever figure this out? I am getting a similar set of errors, and I'm not using React!
I found a way to stop it for a single app. I looked up a way to create a blank service-worker.js file and made it available to my server.
Unfortunately I cannot say I got to the bottom of this. But here is what my service-worker.js file looks like
// A simple, no-op service worker that takes immediate control.
self.addEventListener('install', () => {
// Skip over the "waiting" lifecycle state, to ensure that our
// new service worker is activated immediately, even if there's
// another tab open controlled by our older service worker code.
self.skipWaiting();
});
/*
self.addEventListener('activate', () => {
// Optional: Get a list of all the current open windows/tabs under
// our service worker's control, and force them to reload.
// This can "unbreak" any open windows/tabs as soon as the new
// service worker activates, rather than users having to manually reload.
self.clients.matchAll({type: 'window'}).then(windowClients => {
windowClients.forEach(windowClient => {
windowClient.navigate(windowClient.url);
});
});
});
*/
I added it into the public folder, that stops the messages for me.
Thanks for the quick response! I still don't know what the issue was for me, but based on some searches that said that the browser might actually be restarting the service workers (or trying) based on another app, I simply switched the rails development server from listening on part 3000 to listening on port 4000 ( rails s -p 4000, and hit that url: localhost:4000.) That fixed that (sort of).
Closing the issue based on the above conversations.
Specs:
Issue: Getting these ever present error messages destroying my logs with backtraces. They happen after I set up a rails 5 app with react. The errors are all looking for routes for javascript/workbox/ files once I start the server with
rails s
Notice the errors begin on the last line and will continue from there for each of those GET requests. Followed by a stacktrace for each like this one
What I did: I followed instructions from multiple sources (Here's 1 and another) telling me to do basically the same thing. I ran
rails new app --database=postgresql --webpack=react
which runs normally. Then I add the gemreact-rails
to my gemfile andbundle install
again. I next runrails generate react:install
and everything seems fine except for a few warnings. Here are some of the warnings, I don't know if these are causing the issue or not.Not sure if those warnings matter or if there is another reason that my app isn't setting up Workbox properly.
React itself is working. The default Hello world rails app works fine. It is just the constant failed GET requests to Workbox files that is causing me grieve.
What I've tried to fix it I've tried re-creating new react apps using the instructions I showed above but I run into the same problem.
I've also looked through stackoverflow questions for anyone else with a similar issue.