We need to add some safeguards into Real Time Preview that prevent very long-running or rapid requests to the action=parse API.
Slack thread where the Editing team brought our attention to this:
https://wikimedia.slack.com/archives/C02CDL76HEH/p1645485371745649
Acceptance criteria:
- Ensure there's no more than one in-flight request to the API at any time
- If the wikitext is changed while a request is in flight, a final request should be made after the current one finishes to ensure the preview is up-to-date.
- Average the response time from the server over say 3 requests, and if it is greater than say, 10 seconds (configurable), disable Real Time Preview
- For now this can simply show an error message. Designs and switching to a 'manual refresh' workflow can be implemented later once we have the designs
-
Don't load Real Time Preview at all for very large pages (say 300K bytes)(we've decided not to do this since the previous safeguard will effectively cover this scenario as well) - These thresholds should have configuration settings so 3rd party wikis can control the behaviour based on how their production environment performs.
The thresholds can and may need to be adjusted after we test how Real Time Preview performs in a production environment such as Test Wikipedia.