How to unregister a service worker when the PWA has been trashed - progressive-web-apps

This might sound like a dumb question, but here's the problem. I am developing a PWA for a client and everything works fine : the service worker gets installed, as well as the app on the desktop.
I know how to uninstall both the app and the service worker programmatically.
But, for instance on an old Samsung tablet running Android 4.4, the app icon can be dragged to the trash on the desktop (like any shortcut) and then the app is uninstalled, but the service worker is still active and running (I can see it in DevTools).
Question : how to get rid of service workers after a PWA has been trashed that way ?
My concern is that end users of the app might delete it that way, and still have a service worker active on their mobile...
Thanks in advance.

The process for a service worker will automatically stop running after a short period of idleness–somewhere between under a minute to maybe 5 minutes, depending on the browser and operating system.
If you have Chrome's DevTools open, then that will artificially keep the service worker process alive indefinitely, to aid in debugging. (It would be frustrating if you were trying to debug something related to the state of the service worker, and the service worker process stopped right in the middle.)
This only applies when you've got DevTools open, though, so you should have faith that it will stop on its own if you're not "looking" at it.

Related

Running Fiddler as a scheduled task. Traffic not captured

I have a machine setup to run automated tests. I have some software, including Fiddler running as scheduled tasks on start up without user required to log in.
But tests fail, since traffic is not going through Fiddler. When I log in to that machine, I can see in Task Manager Fiddler running as background process.
I've tried starting the task as my user and as System.
Trying to figure out how to have traffic go through that fiddler instance. Thank you!
4/27 Update
So it had to do with the user that scheduled task was set to run from. After playing with it, I figured my user was set incorrectly. Now it looks like traffic goes through Fiddler, as tests are passing. But nowhere I can see the traffic. Fiddler is running as background process and I can't find the folder where it stores temp files. I have also tried setting autosave to a file every 5 minutes. And while it works when I run fiddler in UI, no sessions are saved when it runs as background process.

Prevent IIS Site and/or app Pool from starting

I have a Powershell script that puts a Windows 2012R2 IIS(v8.5) Web server in "maintenance mode" by stopping a site and its associated app pool. (Stop-WebAppPool and Stop-Website cmdlets). However, if I run iisreset or reboot the server, that site and app pool are put back in a started state automatically.
The Start Mode on the app pool is set to "OnDemand".
"Preload Enabled" is set to False on the site.
Here's the interesting part. If I manually stop the site/pool using the IIS Mgmt Console, the stopped state "survives" an iisreset or server reboot. So, there seems to be something fundamentally different between what the console does and what powershell/code does.
I also tried using appcmd.exe commands instead of the PS cmdlets, same thing: Site and pool were automatically started after reset or reboot.
Has anyone experienced this? Any suggestions. I need this site to remain stopped after an iisreset or reboot so that it doesn't become live while performing maintenance.
Its a pretty basic site, so I've thought about just deleting and re-creating, but that seems a pretty extreme measure. Hoping somebody has a less intrusive method.

Disable force stop option for a service or an activity

I have a requirement to create a service that cannot be stopped by end user.
If the OS kills it, it is fine.
I have seen some processes that I am not able to quit. I need help on how this is possible.
For example, if i launch a 2.3 emulator and check the running services, one of the service - Japanese IME input does not a contain a stop option.
I cannot stop this service. Similarly with Swype. How is it possible to create such a service.
Thanks in advance.

Windows Service "Starting"

I have a critical windows service that I need for my web application.
Unfortunately, the windows service does not start properly, but remains in a status of "Starting" for about 7 minutes and 38 seconds, and then fails.
My web application works fine when the service is in the "Starting" mode.
I have a windows scheduled task that runs every minute to restart the service if necessary.
net start "my service"
Therefore there is a gap of about 22 seconds from when the service fails until it starts up again. In additional it takes an additional 30 seconds or so for my application (which is dependent on this service) to start working.
I have intentionally not named the errant service. I did open a separate question https://stackoverflow.com/questions/8470975/oracle-oc4j-service-keeps-stopping whose aim was to actually solve the problem.
In this question, I am not trying to solve the problem, but rather find a workaround to try and keep this service in a status of "Starting" the whole time.
What is infuriating, is that until I restarted the server today, my workaround of restarting the service every 3 minutes actually worked, with no application downtime whatsoever.
Does anybody have any suggestions? I did try changing the registry key of ServicesPipeTimeout to 86400000 (24 hours!) in a bid to keep the service in the status of "Starting" for longer.
I have found a possible solution to my problem that I am very uneasy about...
I downloaded WinDbg from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=8279
I opened WinDbg and did Attach to Process, and selected my service.
As long as WinDbg is open, it seems to "hold" the process and prevent it from stopping.
How long it will continue to do so, remains to be seen, but it has held for over half an hour now (whereas before the service stopped after 8 minutes)
If you have the timeout set to 24 hours and the service does not start or stay in 'starting' mode , then it must be either crashing or closing itself down.
If you want to try to restarting your service immediately it crashes, then, on the properties of your service, select the 'Recovery' tab. You should be able to set the service to restart on first, second and subsequent failures and set the service to restart after 0 minutes,
Note, this will not work if windows thinks that the service is closing down properly.
It should go without saying that this is a last resort only if you can't get whoever wrote the service to fix the problems.
Try specifying 'Restart the Service' for all three sections on the Recovery tab, but that will only work if the service is ending abnormally.
Our company faced a similar problem and we developed Service Protector, a commercial application that can babysit a service and keep it running 24/7. It may work in your situation too.

Stopping the service and the babysited application before uninstalling

I have a service MyService.exe that is babysitting my application MyApp.exe, meaning it starts the application when this one crashes or whatever. Basically when the service is stopped the application is stopped (by the service) and when the service is started the application is started by the service.
In order to stop my service and by that my application when uninstalling I'm doing:
<ServiceControl Id='MyServiceControl' Name='MyServiceForTest' Start='install' Stop='uninstall' Remove='uninstall'/>
But when I want to uninstall everything I get the error message: "The setup must update files or services that cannot be updated while the system is running. If you choose to continue, a reboot will be required to complete the setup.". If I manually stop the service before running the uninstaller I don't get this msg as both my service and my application aren't then running anymore.
In the log file I noticed that this happens in InstallValidate and I get this message b/c of MyApp.exe being running.
I think what happens is: the uninstallers checks the running applications, it notices that the MyService.exe and MyApp.exe are both running, detects probably that the MyService.exe will be stopped by the uninstaller itself as instructed, but doesn't know about the MyApp.exe that this one will also be terminated once the service will be stopped so it will show the reboot-message.
I can't just close MyApp.exe from uninstaller b/c the service will restart it again.
How could I solve this problem so that the user won't need to reboot or to manually stop the service before doing an uninstall/upgrade? Also, I can't change MyService and MyApp code anymore so I will have to do this from the (un)installer only.
TIA,
Viv
I would expose a mechanism in your service in which your installer can instruct it to stand down and terminate the application. This way when Windows Installer costing looks for locked files it doesn't find any.