[FEATURE] Support Maintenance Mode 🚧
It would be cool if PWA Kit allowed displaying a "Be right back!" maintenance screen when the associated B2C Commerce instance is in maintenance mode.
B2C Commerce instances can enter maintenance mode two ways:
- In BM, you can put your Site's Status into Maintenance.
- During the B2C Commerce release process, Salesforce might put your instance into Maintenance.
When B2C Commerce maintenance mode is enabled, requests to SCAPI return an HTTP 503:
https://developer.salesforce.com/docs/commerce/commerce-api/guide/response-handling.html
Today, when a request to SCAPI returns an HTTP 503, PWA Kit renders a generic error.
There are a few ways we could implement this, but one way would be to propogate HTTP 503 errors from SCAPI calls upward to our <ErrorBoundary>.
We might then add special handling for the case where the error is a 503 to <Error>, displaying a user configurable maintenance page.
It looks like lots of the plumbing is already there – we likely need to need to a) make sure errors are passed enough b) make sure we have the details of the error to act on.
For the implementation, we'd want to test maintenance mode being enabled in a few different places:
- Server side rendering
- Landing on a cached page as a new visitor (eg. call to oauth2/authorize fails)
- Landing on a cache page as a returning visitor with valid token (eg. catagory load fails or requests made to navigate to PLP fail)
- Basket modifications from the cart page
- Basket modifications from the checkout
This feature should also help you understand when the ODS you're connecting to is stopped or or longer exists.
SCAPI requests to a stopped sandbox returns an HTTP 521 "Web server is down" response.
This should result in a clear error message.
Right now we get this:
The issue only becomes clear when you open DevTools: