-
Notifications
You must be signed in to change notification settings - Fork 13
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
Service worker stuck on "trying to install" - install() runtime methods not being called. #6
Comments
Hi @oller, The fact that sw.js step "trying to install" stuck is very strange. You are right about function part being different.
But in your Webpack 5 version it starts with :
Could you try to put 'ES5' in your wepback configuration to see if it makes any differences ?
Yours faithfully, |
Thanks for the response, I have been working on this for a few days, it just gets weirder! I'll try what you've mentioned, but for more context, the webpack 5 service worker works in firefox, it's a chromium specific issue. and if I comment out some files, it'll register correctly. I even tried swapping around the function block of sw.js, so the webpack4 compiled one with the webpack5 config object, and that worked fine (once files were commented out). So I don't think the issue is with the js minification or es6 etc. However there doesn't seem to be any logic to the files I comment out, I can have some files that work (in the array at the top of the sw.js), then another few files in the array that worked standalone too, however when I try them both, it'll get stuck in this state. This is just playing with small svg files i'm commenting in and out. So it seems it's not about the content of the files, but the number of filesize..? I wouldn't say the app is exccessive in size - this is a dump of the analysis of stats.json (before gzip) 🤔 |
The fact that it works on Firefox but Chromium is very strange. Indeed, your application is not that big and I do not think it could come from heavy content as our app take more than 20 MB without any trouble. If this can help you, here is a pastebin of the sw.js on our website which is running on Webpack 5 + Offline Plugin 5.1.0 : |
OK great, much appreciated - i'll keep investigating. Thank you again for your responses and the time taken to fork this repo. |
OK, so having worked my way through the assets in the sw.js commenting those in and out and re-testing. I've got it down to 4 specific files, if any of which are included, the service worker will fail to install. "/robots.txt"
"/" // which is "index.html" before plugin performs 'rewrites'
"/public.html" // a secondary entry point we have
"/favicon.svg" Seeing as these are small files and not really the core of the application, for now i've excludes: ['**/robots.txt', '**/favicon.svg', '**/index.html', '**/public.html'], I've no idea what is special/different about these files that they become an issue (apart from they're all on the root where most are within an Just adding this update in case it's of use to anyone! Relevant to today: |
Nice that you successfully identify which files are causing you some troubles ! Do you confirm that these files are present in your final dist folder ? What you could try :
Yours faithfully, |
maybe related: NekR#486 |
Yeah, I'm pretty sure the issue is related to NekR#486: The The solution is to I started to create a patch (patch for src/misc/sw-template.js, that actually solves the problem discussed here) and wanted to create a PR but the offline-plugin code seems rather obscure to me and I found some likely bugs along the way (mutation of the |
Hey guys, first off thanks for your work on making this plugin webpack 5 compatible!
I was wondering if you had any insight into an issue i'm having.... This same code used to work with webpack4 and the original plugin, now having moved to webpack5 and your fork, none of these console.log() are executed at all.
I've installed your fork, and updated the references to your plugin both at the webpack config and from the app.js to reference this runtime.
I know ServiceWorkers can be a little sticky, so just wanted to get your thoughts if i'm doing something silly, or if there are any other steps i'm not aware of when upgrading.
In devTools I can see the
sw.js
seems to get stuck on 'Trying to install'. Again this is with Brave and Chrome was never previously an issue. I believe this to be at the heart of the problem, the service worker isn't registering.For additional context - the 2 generated sw.js files:
webpack 4 + original offline plugin: https://pastebin.com/zwSrCHFC
webpack 5 + this fork : https://pastebin.com/hT1Zsn4b
The config options at the top seems the same shape (albeit with a few changes as a result of the migration) however the function part at the bottom seem very different.
Any input much appreciated.
Many Thanks!
The text was updated successfully, but these errors were encountered: