JeremyLikness / MvpSummitTaskList

Example in MVP summit of using connected services and adding (persisted) SQLite to Blazor Wasm.
MIT License
25 stars 6 forks source link

uncaught in promise caches is not defined. #3

Closed odyyudah closed 1 year ago

odyyudah commented 2 years ago

the MvpSummitWasm webassembly is working fine on https://localhost but it has error after deployed on server during opening the Cache. the error happened when the caches.open run in http or on server. the quickfix was enabling a flag in google chrome browser version 100: chrome://flags/#unsafely-treat-insecure-origin-as-secure

: image image

blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: Could not find 'db.synchronizeDbWithCache' ('db' was undefined). Error: Could not find 'db.synchronizeDbWithCache' ('db' was undefined). at http://clddweb03:8023/_framework/blazor.webassembly.js:1:328 at Array.forEach () at a.findFunction (http://clddweb03:8023/_framework/blazor.webassembly.js:1:296) at _ (http://clddweb03:8023/_framework/blazor.webassembly.js:1:2437) at http://clddweb03:8023/_framework/blazor.webassembly.js:1:3325 at new Promise () at Object.beginInvokeJSFromDotNet (http://clddweb03:8023/_framework/blazor.webassembly.js:1:3306) at Object.St [as invokeJSFromDotNet] (http://clddweb03:8023/_framework/blazor.webassembly.js:1:59853) at _mono_wasm_invoke_js_blazor (http://clddweb03:8023/_framework/dotnet.6.0.3.ro43xw3px8.js:1:175078) at http://clddweb03:8023/_framework/dotnet.wasm:wasm-function[2566]:0xaebe9 Microsoft.JSInterop.JSException: Could not find 'db.synchronizeDbWithCache' ('db' was undefined). Error: Could not find 'db.synchronizeDbWithCache' ('db' was undefined). at http://clddweb03:8023/_framework/blazor.webassembly.js:1:328 at Array.forEach () at a.findFunction (http://clddweb03:8023/_framework/blazor.webassembly.js:1:296) at _ (http://clddweb03:8023/_framework/blazor.webassembly.js:1:2437) at http://clddweb03:8023/_framework/blazor.webassembly.js:1:3325 at new Promise () at Object.beginInvokeJSFromDotNet (http://clddweb03:8023/_framework/blazor.webassembly.js:1:3306) at Object.St [as invokeJSFromDotNet] (http://clddweb03:8023/_framework/blazor.webassembly.js:1:59853) at _mono_wasm_invoke_js_blazor (http://clddweb03:8023/_framework/dotnet.6.0.3.ro43xw3px8.js:1:175078) at http://clddweb03:8023/_framework/dotnet.wasm:wasm-function[2566]:0xaebe9 at Microsoft.JSInterop.JSRuntime.d__16`1[[System.Int32, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext() at MvpSummitWasm.Data.SynchronizedSummitDbContextFactory.SynchronizeAsync() at MvpSummitWasm.Data.SynchronizedSummitDbContextFactory.CheckForPendingTasksAsync() at MvpSummitWasm.Data.SynchronizedSummitDbContextFactory.CreateSummitContextAsync() at MvpSummit.Domain.DbSummitTaskService.GetTasksAsync() at MvpSummitUi.MvpSummitTaskListComponent.RefreshUiAsync() at MvpSummitUi.MvpSummitTaskListComponent.OnInitializedAsync() at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task , ComponentState )

JeremyLikness commented 2 years ago

Are you accessing it from a hosted app? My best guess is that it is pre-rendering on the server where caches is unavailable. I wrote this for a static (not hosted) target. I'll go ahead an research how to delay the call during pre-rendering.