Skip to content

[MR Widget Eng] - Improve polling behaviour

This issue is the result of a brainstorming session to improve the polling behaviour on the frontend without requiring additional backend work.

Context

The backend returns 204 and a Polling-Interval header when the pipeline is still running: https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/controllers/projects/merge_requests_controller.rb#L518

This information is enough for us to display the following states in the frontend:

  • Loading
  • Still parsing reports
  • Pipeline finished with not data
  • Pipeline finished with data

This issue will capture the necessary work in order to handle these states.

Implementation plan

The plan is to use the successCallback to understand the state and update the extensions accordingly.

This requires that that the widgets do not modify the response while fetching the reports. For instance, the following implementation should be avoided when polling is turned on because we the status and headers properties inside the successCallback:

fetchReport(endpoint, reportType) {
  return axios.get(endpoint).then((res) => ({ ...res.data, reportType }));
}

The successCallback will then check the headers and status code and stop polling when the Polling-Interval header is no longer provided.

Edited by Savas Vedova