Skip to content

Fix pagination and duplicate requests in environments page

Stan Hu requested to merge sh-wip-fix-duplicate-env-xhr into master
  1. When a user clicked on another page, the app would fetch the new page data but never update because the request and response parameters failed to match the isEqual check. This was happening because the JSON response omitted the nested attribute, so there was a comparison with a null value. We fix this by scrubbing undefined values before doing the comparison.

  2. There were duplicate requests made for the environments page because the success handler of fetchPipelines() would cause the polling component to make another XHR request.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/58191

To test this locally, I seeded a project with lots of environments:

diff --git a/db/fixtures/development/19_environments.rb b/db/fixtures/development/19_environments.rb
index 3e227928a29..8ba911ed06f 100644
--- a/db/fixtures/development/19_environments.rb
+++ b/db/fixtures/development/19_environments.rb
@@ -9,8 +9,12 @@ class Gitlab::Seeder::Environments
     @project.create_mock_deployment_service!(active: true)
     @project.create_mock_monitoring_service!(active: true)

-    create_master_deployments!('production')
-    create_master_deployments!('staging')
+    30.times do
+      test = SecureRandom.hex(8)
+      create_master_deployments!("production-#{test}")
+      create_master_deployments!("staging-#{test}")
+    end
+
     create_merge_request_review_deployments!
   end
Edited by Stan Hu

Merge request reports