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

fix: race condition in decorateIcons #256

Closed
wants to merge 1 commit into from
Closed

Conversation

karlpauls
Copy link
Contributor

@karlpauls karlpauls commented Sep 7, 2023

Fix #217

When the same icon is requested several times (like a logo in the header and the footer) there is a race condition in the decorateIcons function that will cause only the first request to get the actual svg while the other requests will get empty icon tags.

This PR fixes this by replacing the current logic that is based on just putting a boolean in the cache while the icon gets loaded with a promise that is put into the cache (similar to what happens in fetchPlaceholders). Subsequently, that promise is returned from the cache for all requesters - hence, they all get the result.

We used this patch in our project and haven't had any issues since then.

Test URLs:

@aem-code-sync
Copy link

aem-code-sync bot commented Sep 7, 2023

Hello, I'm Franklin Bot and I will run some test suites that validate the page speed.
In case there are problems, just click the checkbox below to rerun the respective action.

  • Re-run PSI Checks

@aem-code-sync
Copy link

aem-code-sync bot commented Sep 7, 2023

Page Scores Audits Google
/ PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@kptdobe
Copy link
Contributor

kptdobe commented Oct 2, 2023

Fixed in adobe/aem-lib#12

@kptdobe kptdobe closed this Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

multiple calls to decorateIcons leaves icons empty
2 participants