SAP / spartacus

Spartacus is a lean, Angular-based JavaScript storefront for SAP Commerce Cloud that communicates exclusively through the Commerce REST API.
Apache License 2.0
737 stars 381 forks source link

Service worker should gracefully handle backend maintenance/unavailable status #5882

Open neilhubertprice opened 4 years ago

neilhubertprice commented 4 years ago

Spartacus installs a Service Worker locally to handle repeat visits to the website. However that currently only caches a few assets + homepage/basesite details. It is quite possible for the backend server to be in maintenance mode (503 status in CCv2) or otherwise unavailable. If Spartacus is to be used as a public-facing website for our customers, it should have some form of graceful handling of these backend statuses - so that the non-technical end-users receive understandable responses in their cached implementation & that it can recover if the backend later becomes available.

This does not necessarily have to be a complex UI piece, just some sort of splash page that is customisable during implementation to display an appropriate static message. I.e. logically equivalent to the maintenance page that is used server-side within CCv2

tobi-or-not-tobi commented 4 years ago

While this pattern is currently seen on a stack with a single backend, going forward we'll combinations of backend requests, where a single service might be in maintenance mode. For example, just the Search Service or Cart Service might be offline, while other services will still function. Customers can also adapt third-party/custom backends which are not in our control.

Moreover, the more we code-split the application and apply caching to both static and dynamic resources, the more likely parts of the UI might still remain.

The above should be taken into account when this maintenance feature is going to be designed. Instead of going to a maintenance page / waiting room for the complete app, it would be great to see partial locked down areas of the application if possible.

We could think of throwing warnings/errors based on failing backend requests, or close down various routes. Ideally the user can do as much as possible with clear messaging around locked areas.

neilhubertprice commented 4 years ago

Not disagreeing but ... we have customers currently implementing Spartacus with a single backend, whereas the multi-service approach is a little further in the future. I would not want a simpler solution for those customers to be held up because of work on the full bells-and-whistles version ...

It seems to me that there are two different things here: the capability for an application-wide 'maintenance' mode vs handling of individual services.

Xymmer commented 3 years ago

removing milestone so that re-review this ticket in triage

neilhubertprice commented 3 years ago

@Xymmer Any particular reason why this was closed ?????

Xymmer commented 3 years ago

we are closing old tickets that have no activity. can you indicate importance of this one? i reopened it

neilhubertprice commented 3 years ago

It is difficult to sure on this one, as I am not involved end-to-end on any of the implementation projects. I expect that each project is currently rolling their own approach to deal with this. I also expect that this is partially obscured in CCv2 by the issues around changing file hashes in the jsapps aspect -> meaning the Angular PWA behaviour does not quite work the way it is supposed to.

My experience from older non-PWA sites is that these sort of issues are often not noticed in the original implementation phase, but come back again once the site has been in production for a decent length of time + people start noticing behaviour around releases. That said .... with rolling updates there may not be much downtime / maintenance to notice.

My view: it is likely not urgent right now, but should remain as a requirement for as/when the PWA capabilities are extended in the future

janwidmer commented 2 years ago

@neilhubertprice do you have any inputs on how I could implement some simple static html page in case, the backend is down? we are facing exactly the problem, you described, just having a single backend and needing to show the customer some basic information instead of just nothing, what is the default in spartacus..

alex-alvarezg commented 1 year ago

@janwidmer maybe redirect to the maintenance pages on the JS Storefront? (the 503.html page uploaded in the portal)

janwidmer commented 1 year ago

@alex-alvarezg we ended up, showing some very basic markup which is rendered in the error case. We first used the redirect to a static page (asset of the angular application) but that has the downside, that the user is taken away from his current location and might have a hard time getting back..