Invalid JSON:API responses when maintenance mode is on

Created on 18 April 2019, about 5 years ago
Updated 13 March 2023, over 1 year ago

Problem/Motivation

The issue is fairly straight forward...

Whenever people need to update D8 instructions are the following:
https://www.drupal.org/docs/8/update/update-core-via-composer β†’

... Stuff
Site into maintenance.
... Stuff
Site out of maintenance.

In decoupled context there is no correct way to handle the event -

site is in maintenance mode

.
So there will be public clients hitting the website, as well as jsonapi endpoints fetching data.

The issue with the maintenance mode is easily reproducible:
1. Have public read access against jsonapi endpoints.
2. Enable site maintenance mode.
3. You get a non-valid jsonapi response and broken clients. Note that from the headers of the response clients can not distinguish that it's a maintenance mode response or some reverse proxy interrupted the request.

This is preventing safe deploys on systems running jsonapi or other modules used in decoupled context. In production environment when the system is a fully decoupled one, once the site is in maintenance mode - all public clients are down.

Proposed resolution

JSON:API should add it's own maintenance mode middle-ware before the core's existing one.

Remaining tasks

RTBC and commit

User interface changes

None.

API changes

jsonapi has a new setting to set Retry-After header values when the site is in maintenance mode.

Data model changes

None.

Release notes snippet

Maintenance mode now triggers an event to allow custom behaviour. JSON:API uses this event to serve a JSON:API response with Retry-After header when the site is in maintenance mode.

πŸ› Bug report
Status

Fixed

Version

9.4

Component
JSON APIΒ  β†’

Last updated 2 days ago

Created by

πŸ‡§πŸ‡¬Bulgaria ndobromirov

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024