Application cache disappear when offline - service-worker

I have created my service worker with workbox, and it is precaching successful. However, when I go offline, the application cache disappear and it just won't work. I am sure my script is loaded in the top directory of my site. Did I missed anything?

Ok I found out the reason for my issue. If you are debugging with Chrome, make sure you uncheck "Update on reload" when you check "offline", or else your service worker won't work!

Related

importScripts in service worker

I am trying to use IndexedDB through Jakes Archibald's promise-based IDB lib by importScripts but as soon as I select "offline" through Chrome Dev Tools I am getting An unknown error occurred when fetching the script. A funny thing that's happening is that even if shut down my localhost server my app works fine (I have the browser cache disabled through Chrome Dev Tools) on my service worker installed browser but on another, of course, it doesn't.
I've looked into these https://www.w3.org/TR/service-workers/#importscripts, https://github.com/w3c/ServiceWorker/issues/106 resources but I didn't find an fix to my problem.
Any help/explanation would be greatly appreciated.
The problem is likely to be that you've not cached the idb.js file so that the service worker can access it when your app is offline.
Try adding it using cache.add (or cache.addAll if you are caching multiple files) inside your install callback.
Here is a library that i created. It makes using IndexedDB a whole lot easier! completely client-side, no dependencies!
https://github.com/ryanwaite28/promise-db

Using browserSync, the websocket connection does not initialize until after files have changed

Essentially the problem is that BrowserSync isn't "syncing" until after I change a file for the first time, thus the first "refresh" doesn't come for free.
Background:
I'm setting up a very simple repository where we have a gulp process that generates static files to be served by browserSync. Gulp watches those files, and when they change causes browserSync to reload.
Even though the index page serves seemingly fine, the automatic refresh does not work until AFTER you've both changed a watched file for the first time and then refreshed the browser manually.
I've confirmed this by watching the network tab in Chrome's developer tools, and can see that on first load, there is no websocket present until I manually change a file. Then, after I refresh the browser I can see a proper websocket running. It doesn't matter how many times you refresh the page before you change a file, the websocket will simply not initialize.
I've asked in the BrowserSync slack, checked their issues and read the source code and still can't figure out why this is happening.
If needed I can update the question with the relevant parts of my various related files:
Dockerfile
docker-compose.yml
gulpfule.js
I created a screencast gif, but the whole thing is about 20mb - so I didn't upload it.
Thanks in advance for any help.
BrowserSync in terminal on first load:
Network tab on first load - no websocket:
After I change a file:
Network tab after first changed file - with websocket:
Solved
I created a loader.html with a simple javascript that would do a pre-flight request against my local docker IP/port (3000) associated with my BrowserSync project. On the catch, I would just let it loop every 1000ms and on success, I would redirect.
This is where the problem was introduced.
I was doing the pre-flight request on the same IP/port that I was redirecting to, and for some reason the "websocket" was getting "cached" from my pre-flight check and then wouldn't re-initialize on the redirect or any subsequent refreshes.
My solution was to pre-flight check for BrowserSync's UI port which is 3001 not 3000. Once that was up, I could redirect to the IP:3000 without any problems.

No matching service worker detected: webapp running in sub-directory

I'm getting the follow error-msg in the console when I try to 'add to homescreen'
Site cannot be installed: no matching service worker detected. You may need to reload the page, or check that the service worker for the current page also controls the start URL from the manifest
Register the service-worker did went fine and seems to be ok:
chrome application-Service Worker
It must something to do with the scop since I'm running my site in a sub-domain(/webconnect/):
The manifest has the following values for scope and start_url:
"scope": "/webconnect/"
"start_url": "/webconnect/index.html"
I've gone through the troubleshoot section but this didn't helped me a lot:
Troubleshooting
If after testing you are getting the following error in your console:
No matching service worker detected. You may need to reload the page, or check that the service worker for the current page also controls the start URL from the manifest
Then please make sure that 1. Your service worker is functioning properly and without errors, and 2. Your start_url matches an actual url of your website that loads. Else, you will never get the prompt to show!
Is there a specific trcik I'm missing to add the site to the homepage?
Place the service worker script file at the root of your website (/webconnect/), or place it wherever you want and use the scope property and the Service-Worker-Allowed HTTP header as in my other answer.

w3wp process not found

I use Visual Studio 2010 to debug a asp.net MVC project in my local machine. The steps are:
Click Debug and try to attch process "w3wp.exe". However it is not in the list.
I am sure "Show processes in all sessions" is clicked.
w3wp.exe won't show in the running process' unless there is actually an instance of the web application running.
Try to access your web page first, when it is displayed for the first time, try to attach your debugger. The process should now show up.
You need to click Show Processes from All Users at the bottom of the Task Manager list. This is what i needed to do.
Restart IIS
Right click your site >> Manage Website >> Browse
Back into Visual Studio refresh the processes list
Try to check on :"Show Processes for All Users"
When on the 'Attach to Process' window in the bottom left there is a checkbox 'Show Processes for All Users'
An easy way that works ,when w3wp dont appear in the list,open a browser and write localhost ,then enter.After that w3wp appears to list.
Just because an IIS application pool is started, there may not be an
IIS worker process w3wp running. IIS will not start the worker
process until the first web request is received.
In my case, I first launched the application, still could not find w3wp.exe. Then I took the worker process ID from (IIS->Worker Process -> Process Id) and then search by id in the details tab and found it.
Clear the Solution
Rebuild the solution
Reset the IIS by writing the command iisreset in command prompt
Go to IIS and browse your website
Run VS as administrator
Tools -> Attach to process -> Ensure the 'Show Processes for All Users' checkbox is checked -> w3wp.exe
Attach to w3wp.exec
If you are using something like Advanced Rest Client to test routes, call your route again then refresh the list of processes and it will show up
GoTo Web Project properties -> Select (Web) on the left sidebar -> GoTo under (Servers) header -> Click to dropdown and select "Local IIS"
and apply. Then, when you start debugging you will see w3wp.exe on the proccess list.
I just ran into this issue - you may want to also double check your host settings and verify that you are actually pointed to localhost and not a production server.
I forgot I was pointed at a remote server, and thus, though I was accessing the site, it wasn't anything local so w3wp wasn't running, despite my superficially being able to see the site running.
In my case, I have not opened the Visual Studio in Admin mode that is why the w3wp.exe was not showing on the list.
When I opened the Visual Studio in Admin mode, it worked.
Right click on Visual Studio -> Open in Admin mode.
In my case, once I rebuild the web project and raise the limit of Connection Time out (in seconds), it automatically shows in Debug/Attach to Process list and keeps working.
I would just like to share my experience as well for future readers.
Be aware that, in the event that you have a web server cluster configuration (for load balancing etc) the w3wp process might not start on the same machine that you expect it to.
Unless your website is configured to only run on a single IIS instance, the w3wp process might be spinning up on one of the other machines inside of your web cluster.
This might be faulty configuration from the networking team/department or intended behaviour. I don't have the neccessary experience to pin point exactly how it should be configured.
Found a related page on MSDN as well:
https://msdn.microsoft.com/en-us/library/bb742600.aspx
In my case, I needed to connect from one Visual Studio to the process which running from another VS studio window.
The problem was next: one VS was launched with Administrator permissions. For resolving that issue you should launch both VS with Admin perm.
In my case, the problem was that I wasn't running Visual Studio as Administrator. My machine had restarted after an update and relaunched all the previously running processes, but had only relaunched VS in non-admin mode. When I restarted VS in admin mode, the w3wp.exe processes were available again for debugging.
Run the remote debugger as an administrator.
I followed every suggestion to resolve the issue, but it was not until I ran the remote debugger as an administrator that I was able to see the w3wp process
Try the following steps:
Create a virtual path from Solution Explorer.
Go to inetmgr to confirm that your own pool is created.
Go to Attach Process (Ctrl+Alt+P) and show processes for all users.
Then you will see w3wp.exe will be there.
Be aware that even after jumping through all these hoops (kicking off an instance using a web browser, starting your remote debugging session as an admin, ensuring that "show all users" is checked, etc., ensuring you aren't on a server farm, etc), you may still at times be out of luck.
There are times when the remote process, usually a WCF service in my case, simply will not show up in the list of processes to attach to, and there's nothing that can be done about it. I'm always careful to make my target process readily identifiable by keeping it and only it in a certain App Pool. Sometimes you just can't get there from here. This is undoubtedly the most frustrating thing about remote debugging Microsoft has ever done.
my answer is late for sure, but maybe my answer will help someone.
Go To IIS.
Application Pools.
Advance Setting.
enable 32.bit Application.
Make your Application Running Under enable 32.bit Application.

(SC) DeleteService FAILED 1072

Last time I create WAS profile and WASService then I try to config and run many script for learn how to config WAS, Finally it crash so i use wasprofile delete this profile and forgot delete WASService.
Now I found IBM Webphere Application Server service display in services.msc list, so I tried to delete it with WASService.exe -remove command and windows SC command but I got message
C:\Program Files\IBM\WebSphere\AppServer\bin>sc delete "IBMWAS61Service - DEV"
[SC] DeleteService FAILED 1072:
The specified service has been marked for deletion.
make sure the service is stopped, the services control panel is closed, and no open file handles are open by the service.
Also make sure ProcessExplorer is not running.
I had a similar problem and what I did to overcome it was the following:
Stop the service: net stop "ServiceName"
Ensure: the "mmc.exe" process does not exist (The "Services" list window): taskkill /F /IM mmc.exe
Delete the service: sc delete "ServiceName"
C:\server>sc delete "ServiceName"
[SC] DeleteService SUCCESS
Now, if I execute another sc command, what I get is the following:
C:\server>sc delete "ServiceName"
[SC] OpenService FAILED 1060:
The specified service does not exist as an installed service.
But not the 1072 error message
What I've done is go to this location in regedit:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
From here, you will see a folder for every service on your machine. Simply delete the folder for the service you wish, and you're done.
N.B: Stop the service before you try this.
For some buggy reason both Event Viewer and/or Services.msc won't do a proper refresh when you tell them to!
Close them and restart, and the service would have been deleted anyway.
I had the same issue. After I closing and re-opening the Computer Management window the service was removed from the list. I'm running windows 7
In Windows 7, make sure Event Viewer closed before deleting.
I had this error also, make sure the exe the service is pointing to is stopped. Also make sure you don't have any Windows dialog boxes behind your other windows. That is why mine wasn't deleting. There was a windows message behind it saying this service has been deleted or something similar.. just had to click ok, there it went.
I had the same error due to a typo in the service name, i was trying to delete the service display name instead of the service name.
Once I used the right service name it worked fine
Logging-out and logging-in again close all blocking apps thus resolves the problem.
The 3rd party application uninstaller had removed the files for the service and then left the service in this pending deletion state.
After trying to close all applications, identifing PID of service(couldn't) for kill, logging off all other users and logging off and on, rebooting was the only fix that worked for me.
One situation where this can also happen is if there is some other service or application that is holding open a service handle obtained with OpenService. For example, a monitoring service that starts and stops services based on some external event can keep open handles to each of the services it monitors. In this case, uninstalling the service would leave it in the "marked for deletion" state until all handles obtained with OpenService are closed.

Resources