BytexDigital / BytexDigital.Blazor.Components.CookieConsent

Components for handling GDPR cookie consent
https://www.nuget.org/packages/BytexDigital.Blazor.Components.CookieConsent/
Apache License 2.0
43 stars 15 forks source link

Could not find 'CookieConsent.BroadcastEvent' #34

Closed CSHGK closed 3 weeks ago

CSHGK commented 1 month ago

We have upgraded from 1.0.18 to 1.2.0 and now we get the following error on each load/reload:

invoke-js.ts:176 fail: BytexDigital.Blazor.Components.CookieConsent.CookieConsentService[0] Exception raised trying to run CookiePreferencesChanged event handler Microsoft.JSInterop.JSException: Could not find 'CookieConsent.BroadcastEvent' ('BroadcastEvent' was undefined). Error: Could not find 'CookieConsent.BroadcastEvent' ('BroadcastEvent' was undefined). at https://localhost:44312/_framework/blazor.webassembly.js:1:368 at Array.forEach () at l.findFunction (https://localhost:44312/_framework/blazor.webassembly.js:1:336) at w (https://localhost:44312/_framework/blazor.webassembly.js:1:5079) at https://localhost:44312/_framework/blazor.webassembly.js:1:2872 at new Promise () at b.beginInvokeJSFromDotNet (https://localhost:44312/_framework/blazor.webassembly.js:1:2835) at Object.vn [as invokeJSJson] (https://localhost:44312/_framework/blazor.webassembly.js:1:58849) at https://localhost:44312/_framework/dotnet.runtime.8.0.7.urcsr75yt5.js:3:178364 at Tl (https://localhost:44312/_framework/dotnet.runtime.8.0.7.urcsr75yt5.js:3:179198) at Microsoft.JSInterop.JSRuntime.d__16`1[[Microsoft.JSInterop.Infrastructure.IJSVoidResult, Microsoft.JSInterop, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext() at Microsoft.JSInterop.JSObjectReferenceExtensions.InvokeVoidAsync(IJSObjectReference jsObjectReference, String identifier, Object[] args) at BytexDigital.Blazor.Components.CookieConsent.Interop.CookieConsentInterop.BroadcastEventAsync(Boolean isDirectedTowardsWasm, String name, String data) at BytexDigital.Blazor.Components.CookieConsent.Broadcasting.CookieConsentEventHandler.PublishToJsAsync(String name, String data) at BytexDigital.Blazor.Components.CookieConsent.Broadcasting.CookieConsentEventHandler.BroadcastCookiePreferencesChangedAsync(CookiePreferences cookiePreferences) at BytexDigital.Blazor.Components.CookieConsent.CookieConsentService.PublishCookiePreferencesChanged(CookiePreferences preferences) at BytexDigital.Blazor.Components.CookieConsent.CookieConsentServiceAuthority.NotifyApplicationLoadedAsync()

Do you have an idea Thanks

RyanTT commented 1 month ago

Hi, it appears to work in a new project as far as I can see. Are you able to reproduce this issue in a minimal project? I'll check again in a minute what this could be, but at first glance im unable to tell

CSHGK commented 1 month ago

Hi, the error does not occur in a brand new minimal project. But the error occurs in our project also when we only set:

In App.razor: <BytexDigital.Blazor.Components.CookieConsent.CookieConsentHandler @rendermode="@RenderMode.InteractiveWebAssembly" />

In Programm.cs: builder.Services.AddCookieConsent(o => { });

In index.html: < link rel="stylesheet" href="_content/BytexDigital.Blazor.Components.CookieConsent/styles.min.css" />

RyanTT commented 1 month ago

What kind of project structure do you use? Is it a Blazor WebApp with interactive rendering or a 100% server-side or 100% WASM app?

RyanTT commented 1 month ago

I just tried creating a new WebApp project in Visual Studio with global interactivity enabled, and interactivity render mode on auto, then

which worked fine. Could you send me your minimal project where the library did not work? That would greatly help me debug the issue.

RyanTT commented 3 weeks ago

Feel free to comment again and I'll reopen