servicetitan / Stl.Fusion

Build real-time apps (Blazor included) with less than 1% of extra code responsible for real-time updates. Host 10-1000x faster APIs relying on transparent and nearly 100% consistent caching. We call it DREAM, or Distributed REActive Memoization, and it's here to turn real-time on!
MIT License
1.82k stars 106 forks source link

Error Using Session: System.InvalidOperationException: Property Session is not Initialized #675

Open neozhu opened 2 months ago

neozhu commented 2 months ago

I’m currently integrating the Session feature in my project using Fusion, but I'm encountering an error that I need help with. The error message I receive is: System.InvalidOperationException: Property Session is not initialized.

Here’s the configuration I’m using (please include your configuration details here; you can omit any sensitive information).

 services.AddFusion(fusion => {
     fusion.AddInMemoryAuthService();
     fusion.AddInMemoryKeyValueStore();
     fusion.AddAuthClient();
     fusion.AddBlazor().AddAuthentication().AddPresenceReporter();
     fusion.AddService<IUserSessionTracker,UserSessionTracker>();
     fusion.AddService<IOnlineUserTracker, OnlineUserTracker>();
 });

@inherits ComputedStateComponent<UserInfo[]>
@inject IOnlineUserTracker OnlineUserTracker
@inject IStringLocalizer<ActiveUserSession> L
@inject Session Session
@implements IAsyncDisposable
[10:20:32 ERR ::1] Unhandled exception in circuit '6HBk0xzeF0auuhxEMHo44PsVFqsIbK-Ji4ezMFm1Vac'.
System.InvalidOperationException: Property Session is not initialized.
   at ActualLab.Fusion.SessionResolver.get_Session()
   at ActualLab.Fusion.FusionBuilder.<>c.<.ctor>b__12_21(IServiceProvider c)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass2_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
   at Microsoft.AspNetCore.Components.ComponentFactory.<>c__DisplayClass9_0.<CreatePropertyInjector>g__Initialize|1(IServiceProvider serviceProvider, IComponent component)
   at Microsoft.AspNetCore.Components.ComponentFactory.InstantiateComponent(IServiceProvider serviceProvider, Type componentType, IComponentRenderMode callerSpecifiedRenderMode, Nullable`1 parentComponentId)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateChildComponentOnFrame(RenderTreeFrame[] frames, Int32 frameIndex, Int32 parentComponentId)

Could you guide me on the proper setup to use Session correctly within the project? Any help would be much appreciated!

Thank you!

adambajguz commented 6 hours ago

Hi @neozhu, open issue here https://github.com/ActualLab/ It looks like this repo migrated without any notice.