icon
icon copied to clipboard
Race condition: app delays with loading (the same) icon
There is a race-condition that we finally found that was causing our app to "wait" for about 10 seconds.
if (!state.value?.[iconKey.value]) {
isFetching.value = true
state.value[iconKey.value] = await loadIcon(resolvedIcon.value).catch(() => undefined)
isFetching.value = false
}
If your page has 1000s of the same icon, the loadIcon
gets called 1000s of times before the if statement is true. The loadIcon method is slower than nuxt-icon calling this with each icon on the page.
You need to set either another variable that designates that you are already loading this icon, or set state.value[iconKey.value]
with a temporary non-falsy value.