Handle PWA update with API changes - reactjs

I have a PWA built with ReactJS and I have the NetworkFirst policy handled by Workbox, so when I update the front, the service worker detects a new version and download it in the background and this new version is applied only in two cases: when the browser is closed and opened or after 24 hours.
The problem comes when I need to change something in the API (django), for example I change the name of an endpoint and I need to change in the front too. When that happens, I make the release in both, front and back, but with the PWA if it last one day to make the update, during this day the app will be doing calls to an "old" endpoint so it will not work.
I would like to know how to handle this, a newer version of the API when the PWA is not updated yet, or if it is posible to force an update of the PWA when required.
Thank you in advance!

Only make backwards compatible changes to the API. For example you have API v1 (example.com/api/v1/endpoint) deployed, deploy v2 (example.com/api/v2/endpoint) and new frontend that uses API v2. After some time has passed and usage of API v1 has stopped, delete it and have a new backend deploy.

Related

Angularjs deployment strategy

How can I deploy and Angularjs app and ensure that all my users get the update when it happens? I have a breaking change that needs to be deployed and would cause some downstream issues should a user continue using the old version. Are there any tools or best practices on how to handle this?
Like in the comments says you cant do it with session expires, one alternative you can do, its handle in the backend to check if an update was release and with push notifications cand inform to client. Forcing to reload the app.
An intrusive will do the same thing but without notification, only if response tell there is an update reload page, according api response.

managing app engine versions through API calls

Is there anyway that I can manage the appengine versions and instances through API calls?
What I mean by managing is to start/stop/delete versions deployed to the appengine through API calls.
Is that possible by using gcloud sdk commands from command line ?
Another question , does google provide APIs (or commands) to check the status of running instances ? check if the instance is idle or not and how long its being idle
There is a beta API for managing versions and services here:
https://cloud.google.com/appengine/docs/admin-api/
The API is still beta because it's under active development; there are still a few methods and fields which aren't implemented. Shortly after those are complete, the API will be marked "v1", though v1beta4 and v1beta5 will continue to be supported for several months in transition.
For example, the API doesn't yet include operations on instances, but I expect that List/Get/Delete will be available fairly soon. Since App Engine automatically creates instances for you, there is no create instance API.
I just noticed that the most recent documentation re-skin seems to have hidden the documentation for the REST interface, so I'll drop that link there so you that you can find the currently implemented methods. (Version.Update is also implemented for a few fields, so that documentation update should be coming out very soon.)
2020 UPDATE: You can do it using the apps.services.versions api. You can stop/start a version with the PATCH method, setting the mask to "servingStatus" and in the body set the "servingStatus" field to "STOPPED"/"SERVING".
Similarly, you can use the delete/create methods to launch and remove new versions
Reference:
https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions/patch

Google Cloud Endpoint : Request params not delivered to Cloud Endpoints when using Google APIs Client Library for JavaScript

Suddenly my gapi client stopped sending request params to endpoint.
This is how my code looks like
Load the gapi JS
https://apis.google.com/js/client.js?onload=initGoogleApis
in initGoogleApis
function initGoogleApis() {
var ROOT = HOST + "/_ah/api";
gapi.client.load("userendpoint", "v1", function() {
userendpoint = gapi.client.userendpoint;
}, ROOT); }
Now when I query userendpoint.<some function>, then it is not passing the request params to endpoint
NOTE: it was working fine till today morning.
Anyone else facing the same issue? (this might be due to some update in the gapi library)
This issue has been resolved as of yesterday 2014-09-23 08:00 (US Pacific Time).
Details about this issue can be found in the Google App Engine Downtime Notify Group
However 'Google APIs Client Library for JavaScript' is still in Beta and breaking changes have been rolled out more than once. Clound Endpoints themselves are out of beta and can be used for production use.
Now, to properly answer this questions:
The simple advice here is: Don't use beta products for production applications.
To avoid problems with Google APIs Client Library for JavaScript, just don't use it. You can write your own REST API client that will not be affected by changes to the JavaScript library from Google. I have done this for testing purposes a couple of times and it is not hard, just a lot of work depending on how many endpoints you have and how complex they are.
We have the same problem on two projects.
I think that Google has deoployed a new version of the "https://apis.google.com/js/client.js" and it dosen't works as expected...
We need to open a ticket to Google support. If I have any news I will report them to you.
Google reports (https://groups.google.com/forum/#!topic/google-appengine-downtime-notify/t9GElAJwj8U):
We are currently experiencing an issue with Google Cloud Endpoints where the GAPI Javascript client is unable to pass request parameters. For everyone who is affected, we apologize for any inconvenience you may be experiencing. We will provide an update by Tuesday, 2014-09-23 05:00 (all times are in US/Pacific) with current details, and if available an estimated time for resolution.
Update:
We have fixed the issue affecting Google Cloud Endpoints JavaScript client and are gradually rolling-out a fixed version. We estimate full resolution of the issue by 06:30 US/Pacific Pacific. We will provide an update by 06:00 AM.
Update:
Now it works for me.
Marco

AppEngine Cloud EndPoint 404 Not Found with version 2 of my App

I have deployed a new version of my App that contains a new cloud endpoint.
I have made the new version the default version.
I have even deleted the old version (version 1).
If I try to hit https://<myappid>.appspot.com/_ah/api/ then I get a
404 Not Found.
If I try to hit https://2-dot-<myappid>.appspot.com/_ah/api/ then
my request gets served.
It's been a full 24 hours since I uploaded version 2. And more than an hour since I marked version 2 as default and deleted version 1, but I'm still getting the 404.
I don't want to ship my client explicitly pointing to 2-dot-<myappid> as this locks the client to a particular version.
Any ideas on what is going wrong?
Cloud Console currently doesn't automatically update Endpoints when changing app versions. You need to use the old App Engine Admin Console to make it update. So, I suggest trying switching versions to another version and switching back immediately. It should fix it for you.
Upload a new major version of your app. This can be identical to your current default version, which just the version name changed.
Visit the App Engine Admin Console and select your project.
Click Versions.
Change the default version to the one you just deployed.
Change the default version back to the one it just was.
At this point, the default domain should be working for you.
how about trying "https://xandar-wordgame.appspot.com/_ah/api/explorer",it may redirect the page to api-explorer where you can explore your api.
Others:
I've also encountered the same problem. but then I realized I have not changed the javascript code that load the api client. I changed the version in java annotation , but forgot to change the gapi.client.load(_apiName, _version, _your_call_back_function,_apiRoot) in web client .
Hope it will help.

_ah/warmup requests coming with hosts prefixed with app version

I am using the warmup service to carry out precaching/etc. The request gets called with self.request.host being prefixed with a version of the app.
All other handler requests are coming with the expected host name for the app.
So if the app name is myapp - then all requests are called with self.request.host set to myapp.appspot.com, whereas for "_ah/warmup" call it is getting set to nnn.myapp.appspot.com.
My code is expecting the self.request.host to be always 'myapp.appspot.com'. Is this by design or am I missing something.
Thanks.
I think this is by design because the warmup service is for a specific version. All other requests are going straight to your main app URL, which is just "aliased" to whatever version happens to be the default version at the time.
By the way, it is documented that you can access all deployed versions of your app by prefixing the version number to the domain name, so you should be aware that any users could access any version if they know about this, and if you haven't taken countermeasures! So you should definitely support this - it's an official feature of App Engine.

Resources