Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue] Do not send an ajax request if there no affected sections #31948

Closed
4 tasks
m2-assistant bot opened this issue Feb 2, 2021 · 1 comment · Fixed by #31933
Closed
4 tasks

[Issue] Do not send an ajax request if there no affected sections #31948

m2-assistant bot opened this issue Feb 2, 2021 · 1 comment · Fixed by #31933
Assignees
Labels
Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S1 Affects critical data or functionality and forces users to employ a workaround.

Comments

@m2-assistant
Copy link

m2-assistant bot commented Feb 2, 2021

This issue is automatically created based on existing pull request: #31933: Do not send an ajax request if there no affected sections


Description (*)

In the customer data, we have a handler for all ajax requests. If we have some custom JS that sends POST, PUT or DELETE request, it tries to send a request to the backend to reload affected sections. As we had such a request by some tracking - these requests caused an additional request to the backend on all the pages that caused a significant load to the servers.

In case if there are no affected sections, it is still sending requests to the backend.

We got this issue when we created a mixin to the getAffectedSections for Magento_Customer/js/section-config and returning an empty array for our custom URL (request is sent not to Magento, so it can't affect any Magento sections).

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes magento/magento2#<issue_number>

Manual testing scenarios (*)

  1. Open app/code/Magento/Customer/view/frontend/web/js/section-config.js
  2. at the beginning of the getAffectedSections method add following code in console:
            if (typeof url === 'string' && url.indexOf('my-url-not-affecting-sections') !== -1) {
                return [];
            }

image
3. Open frontend
4. open developer tools, execute following JS:

jQuery.post('/my-url-not-affecting-sections');
  1. Go to the "network" tab in the developer tools, review the list of requests

Actual result:
image
❌ request for reloading customer sections was sent to the backend

Expected result
image
✔ request for reloading customer sections shouldn't be sent to the backend

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)
@m2-community-project m2-community-project bot added this to Ready for Confirmation in Issue Confirmation and Triage Board Feb 2, 2021
@gabrieldagama gabrieldagama added Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Feb 3, 2021
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Confirmed in Issue Confirmation and Triage Board Feb 3, 2021
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @gabrieldagama
Thank you for verifying the issue. Based on the provided information internal tickets MC-40740 were created

Issue Available: @gabrieldagama, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@gabrieldagama gabrieldagama added the Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. label Feb 3, 2021
@m2-community-project m2-community-project bot added this to Pull Request In Progress in High Priority Backlog Feb 3, 2021
@engcom-Alfa engcom-Alfa added the Severity: S1 Affects critical data or functionality and forces users to employ a workaround. label Feb 18, 2021
@m2-community-project m2-community-project bot moved this from Pull Request In Progress to Done in High Priority Backlog Mar 7, 2021
@m2-community-project m2-community-project bot moved this from Done to Ready for Development in High Priority Backlog Mar 7, 2021
@m2-community-project m2-community-project bot moved this from Ready for Development to Done in High Priority Backlog Mar 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S1 Affects critical data or functionality and forces users to employ a workaround.
Projects
Development

Successfully merging a pull request may close this issue.

5 participants