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
- Start a project with a
.gitlab-ci.yml. - Open the Network inspector in your browser.
- Filter for
/-/cable. - Open a page to the Repository page. You should see a subscription to
ciPipelineStatusUpdatedin theResponsetab:
- Create a script such as
push.sh:
echo "hello" >> README.md
git add README.md
git commit -m "test"
- Continually push new commits:
while true; do sh push.sh; git push -u origin HEAD; sleep 20; done
- Keep the browser up for a few minutes.
-
gdk restart nginx. - When the browser reconnects, you should only see one
ciPipelineStatusUpdatedfor the latest pipeline:
In contrast, previous to this merge request you would see a spam of requests:
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.


