Unsubscribe from pipeline status updates when pipeline ID changes

What does this MR do and why?

When the pipeline ID changes during polling or when the component is destroyed, properly unsubscribe from the previous pipeline's status updates. This prevents accumulating multiple active subscriptions over time, which could result in hundreds of subscription requests if a tab is left open for an extended period.

The subscribeToMore() method returns an object with an unsubscribe() method, so we now store the subscription and call unsubscribe() when switching to a new pipeline or on component destruction.

References

Relates to #587107

How to set up and validate locally

  1. Start a project with a .gitlab-ci.yml.
  2. Open the Network inspector in your browser.
  3. Filter for /-/cable.
  4. Open a page to the Repository page. You should see a subscription to ciPipelineStatusUpdated in the Response tab:

image

  1. Create a script such as push.sh:
echo "hello" >> README.md
git add README.md
git commit -m "test"
  1. Continually push new commits:
while true; do sh push.sh; git push -u origin HEAD; sleep 20; done
  1. Keep the browser up for a few minutes.
  2. gdk restart nginx.
  3. When the browser reconnects, you should only see one ciPipelineStatusUpdated for the latest pipeline:

image

In contrast, previous to this merge request you would see a spam of requests:

image

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Stan Hu

Merge request reports

Loading