Skip to content

Block ajax requests to the shop while a process runs#1523

Merged
Quetzacoalt91 merged 2 commits intoPrestaShop:devfrom
Quetzacoalt91:block-ajax-requests-during-process
Nov 24, 2025
Merged

Block ajax requests to the shop while a process runs#1523
Quetzacoalt91 merged 2 commits intoPrestaShop:devfrom
Quetzacoalt91:block-ajax-requests-during-process

Conversation

@Quetzacoalt91
Copy link
Member

@Quetzacoalt91 Quetzacoalt91 commented Nov 11, 2025

Questions Answers
Description? Updates are reported to fail randomly. This is caused by the ajax request that check regularly if new notifications should be displayed on the top of the back office. This PR introduces a guard that prevents all ajax requests to reach the shop if they are not related to Update Assistant. This fixes the parallel generation of the cache at a moment we try to empty it.
Type? bug fix
BC breaks? Nope
Deprecations? Nope
Fixed ticket? Fixes PrestaShop/PrestaShop#39509
Sponsor company @PrestaShopCorp
How to test? As reported on the video below, the browser console will now display when the guard is toggled on and off. You can manually send ajax requests by clicking on the bell at the top of the back office page. On the dev branch, you can trigger it when you want and this makes the update fail if called at the end of the update database, while on this PR no ajax request will appear on the network tab.

Note: If requests are sent to the shop from other sources (API, probably front end as well...), Update Assistant won't be able to block them.

Capture.video.du.2025-11-11.16-36-11.mp4

@Quetzacoalt91 Quetzacoalt91 self-assigned this Nov 11, 2025
@Quetzacoalt91 Quetzacoalt91 added the bug Type: Bug fix label Nov 11, 2025
@github-project-automation github-project-automation bot moved this to Ready for review in PR Dashboard Nov 11, 2025
Comment on lines +24 to +44
const dataSet = [
{
urlRequest: '/admin-dev/common/notifications/ack?_token=',
urlShop:
'http://localhost:8001/admin-dev/?controller=AdminSelfUpgrade&token=&route=restore-page-post-restore',
expectedValue: false
},
{
urlRequest: 'http://localhost:8001/admin-dev/common/notifications?_token=',
urlShop:
'http://localhost:8001/admin-dev/?controller=AdminSelfUpgrade&token=&route=restore-page-post-restore',
expectedValue: false
},
{
urlRequest:
'/admin-dev/autoupgrade/ajax-upgradetab.php?route=restore-page-backup-selection',
urlShop:
'http://localhost:8001/admin-dev/?controller=AdminSelfUpgrade&token=&route=restore-page-post-restore',
expectedValue: true
}
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test on an external API?

@Quetzacoalt91 Quetzacoalt91 force-pushed the block-ajax-requests-during-process branch 2 times, most recently from 5ebddab to 09950ed Compare November 13, 2025 11:20
@Quetzacoalt91 Quetzacoalt91 force-pushed the block-ajax-requests-during-process branch from 09950ed to 8ec5fbc Compare November 14, 2025 14:33
@sonarqubecloud
Copy link

Copy link

@ingridusta ingridusta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @Quetzacoalt91,

I reproduced the bug thanks to ur tips, and tested ur pr. It works as expected, no more failed backup/updates/restore and in the console, a message is displayed to show that request are filtered then when the backup/updates/restore is over, the requests are allowed again.

Capture d’écran 2025-11-24 à 17 19 25

5 ⭐, it's QA approved ✅

@ingridusta ingridusta added QA ✔️ Status: Check done, Code approved and removed waiting for QA labels Nov 24, 2025
@Quetzacoalt91 Quetzacoalt91 added this to the 7.5.0 milestone Nov 24, 2025
@Quetzacoalt91 Quetzacoalt91 merged commit a617d5a into PrestaShop:dev Nov 24, 2025
55 checks passed
@github-project-automation github-project-automation bot moved this from Ready for review to Merged in PR Dashboard Nov 24, 2025
@Quetzacoalt91 Quetzacoalt91 deleted the block-ajax-requests-during-process branch November 24, 2025 16:58
@alexandrebrubeyonds
Copy link
Contributor

Thank you for this PR @Quetzacoalt91

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Type: Bug fix QA ✔️ Status: Check done, Code approved

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Issue with Upgrade from 8.2.1 to 8.2.3 - Failed to remove directory: Directory not empty

5 participants