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

StoreInitializationException #535

Open
lrequena opened this issue Mar 10, 2025 · 0 comments
Open

StoreInitializationException #535

lrequena opened this issue Mar 10, 2025 · 0 comments

Comments

@lrequena
Copy link

Summary

After deploying recent changes to production—including DLL version upgrades—we encountered an intermittent StoreInitializationException. The error occurred once per session and did not reappear after a page refresh. My suspicion is that the issue may lie in the way Blazor executes component, route, and page lifecycles during render mode transitions when DLL and WASM upgrades occur. This behavior could explain why the problem does not recur once the DLLs have been updated for that browser/context.

Due to the unique nature of this scenario, I was unable to reproduce the error in either a sample project or in the original development environment where it was first observed.


Error Details

  • Error Message:
    Store initialization error: An attempt was made to transition a task to a final state when it had already completed.

  • Exception Type:
    System.InvalidOperationException

  • Failed Method:
    Fluxor.Store+<ActivateStoreAsync>d__39.MoveNext

  • Problem Identifier:
    System.InvalidOperationException at Fluxor.Store+<ActivateStoreAsync>d__39.MoveNext

  • Assembly Details:

    • Fluxor: Version 6.6.0.0, Culture=neutral, PublicKeyToken=null
    • Innermost Assembly: System.Private.CoreLib, Version 9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
    • Innermost Method: System.ThrowHelper.ThrowInvalidOperationException
  • Formatted Message:
    Unhandled exception rendering component: Store initialization error

  • Call Stack:

Fluxor.Exceptions.StoreInitializationException:
   at Fluxor.Blazor.Web.StoreInitializer+<OnAfterRenderAsync>d__17.MoveNext (Fluxor.Blazor.Web, Version=6.6.0.0, Culture=neutral, PublicKeyToken=null: D:\a\Fluxor\Fluxor\Source\Lib\Fluxor.Blazor.Web\StoreInitializer.cs:102)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer+<GetErrorHandledTask>d__89.MoveNext (Microsoft.AspNetCore.Components, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
Inner exception System.InvalidOperationException handled at Fluxor.Blazor.Web.StoreInitializer+<OnAfterRenderAsync>d__17.MoveNext:
   at System.ThrowHelper.ThrowInvalidOperationException (System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Fluxor.Store+<ActivateStoreAsync>d__39.MoveNext (Fluxor, Version=6.6.0.0, Culture=neutral, PublicKeyToken=null: D:\a\Fluxor\Fluxor\Source\Lib\Fluxor\Store.cs:270)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Fluxor.Store+<InitializeAsync>d__25.MoveNext (Fluxor, Version=6.6.0.0, Culture=neutral, PublicKeyToken=null: D:\a\Fluxor\Fluxor\Source\Lib\Fluxor\Store.cs:115)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Fluxor.Blazor.Web.StoreInitializer+<OnAfterRenderAsync>d__17.MoveNext (Fluxor.Blazor.Web, Version=6.6.0.0, Culture=neutral, PublicKeyToken=null: D:\a\Fluxor\Fluxor\Source\Lib\Fluxor.Blazor.Web\StoreInitializer.cs:87)
  • Relevant Code Location:
    The error appears to be triggered in Store.cs at line 270:
InitializedCompletionSource.SetResult(true);

Context and Reproduction

  • Deployment Changes:
    The error surfaced after pushing updates to production that involved DLL version upgrades.

  • Environment:
    The application uses Blazor with AutoRender mode, which transitions automatically from server to WebAssembly. It appears that the error might be linked to the timing of DLL and WASM updates during the transition.

  • Behavior Observed:

    • The error occurred once during a session.
    • Refreshing the page resolved the issue permanently in that session.
    • The behavior was consistent across different browsers and application contexts where the application was preloaded.

Proposed Change

It is suggested to modify the code from:

InitializedCompletionSource.SetResult(true);

to:

InitializedCompletionSource.TrySetResult(true);

Note: Further investigation is recommended to assess any potential impact of this change.

Additional Information

Please let me know if further details or logs are required. I am available to help with additional investigation.

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

No branches or pull requests

1 participant