Have you a custom ClientResourceExtensions.RequiredClientResources (Or something else) that might already be adding a defer attribute to scripts ?
Would it be possible to run this code somewhere:
string TrackingScriptName = "epi.find.trackingScript";
var clientResourceService = ServiceLocator.Current.GetInstance<IClientResourceService>();
var trackingScripts = clientResourceService.GetClientResources(TrackingScriptName, new[] { ClientResourceType.Script }).ToList();
what can you see in trackingScripts ? It seems like you have duplicated resource registration in your module.config.
We don't have any custom for this ClientResourceExtensions.RequiredClientResources.
Quan,
I tried to run the code and what i see in trackingScripts is zero for the first time but when i refresh the page again i notice there is one script for "epi.find.trackingScript" which has a defer attribute already which is breaking the page.
In startup file, registering the services.AddSingleton<IClientResourceService, ClientResourceService>();. After removing this service regsiter the site is now working as expected.
Before adding the find to the application, the site intially working with service(IClientResourceServic) register. Any thoughts around this?
Do you have AddCmsFrameworkWeb() ? it would call that registration already
I think it register ClientResourceService as Transient, which is why when you regsiter as AddSingleton things will be called twice.
For us, this was/is an issue with Custom Error hanldling, i.e. when a page is loaded the EPiServer.Find.UI.ScriptInjection class is called, adding the script to the required client resources. Then when a 500 error is encountered, the custom error page is served instead. During the rendering of the custom error page, the EPiServer.Find.UI.ScriptInjection is called a second time and tries to add the 'defer' attribute again to the dictiorary. This leads to the exception, ‘ArgumentException: An item with the same key has already been added. Key: defer’
This has been accepted as a bug... but I'm still waiting for the fix
https://world.optimizely.com/support/Bug-list/bug/FIND-12783
For us, this was/is an issue with Custom Error hanldling, i.e. when a page is loaded the EPiServer.Find.UI.ScriptInjection class is called, adding the script to the required client resources. Then when a 500 error is encountered, the custom error page is served instead. During the rendering of the custom error page, the EPiServer.Find.UI.ScriptInjection is called a second time and tries to add the 'defer' attribute again to the dictiorary. This leads to the exception, ‘ArgumentException: An item with the same key has already been added. Key: defer’
This has been accepted as a bug... but I'm still waiting for the fix
https://world.optimizely.com/support/Bug-list/bug/FIND-12783
We have recenlty upgraded the solution from .net 5 to .net 6 using the Episerver.CMS 12.5.1 version and the website works as expected. Now we are including the Episerver.Find.CMS(14.2.4), and also we haven't made any customization around Find dll. After this, we are able to access the url: Episver/Find/ and i can do the indexing of the pages as well, navigate through pages on the conosle level.
But the issue is on the front end side, when i tried to access any page from webssite it works for the first time and the site breaks either if i naviagte to other pages or refresh the current page. Here is the error
I have tried with 15.0.0 of EPiserver.Find.CMS to see if helps to resolve the issue but no luck there.
Happy to know if you have any guess around this isuse.