Система прерывистых ошибок.Исключение ObjectDisposedException: Не удается получить доступ к удаленному объекту

#aspnetboilerplate #graphql-dotnet

Вопрос:

Чтобы дать больше контекста, у нас есть ASP.NET Базовая платформа abp с настройкой GraphQL. Все это работает хорошо, но когда мы развертываем это в среде с балансировщиком нагрузки, происходит сбой с ошибкой ниже.

Ошибка

     Object name: 'Scope cache was already disposed. This is most likely a bug in the calling code.'.
   at Castle.MicroKernel.Lifestyle.Scoped.ScopeCache.get_Item(Object id)
   at Castle.MicroKernel.Lifestyle.Scoped.DefaultLifetimeScope.GetCachedInstance(ComponentModel model, ScopedInstanceActivationCallback createInstance)
   at Castle.MicroKernel.Lifestyle.ScopedLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)
   at Castle.Windsor.MsDependencyInjection.MsScopedLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)
   at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burdenamp; burden)
   at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)
   at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, Arguments additionalArguments, IReleasePolicy policy, Boolean ignoreParentContext)
   at Castle.Windsor.MsDependencyInjection.ScopedWindsorServiceProvider.GetServiceInternal(Type serviceType, Boolean isOptional)
   at Castle.Windsor.MsDependencyInjection.ScopedWindsorServiceProvider.GetService(Type serviceType)
   at GraphQL.Utilities.ServiceProviderExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) in C:projectsgraphql-dotnetsrcGraphQLUtilitiesServiceProviderExtensions.cs:line 38
   at GraphQL.Types.Schema.<CreateTypesLookup>b__68_1(Type type) in C:projectsgraphql-dotnetsrcGraphQLTypesSchema.cs:line 314
   at GraphQL.Types.GraphTypesLookup.AddTypeIfNotRegistered(Type type, TypeCollectionContext context) in C:projectsgraphql-dotnetsrcGraphQLTypesGraphTypesLookup.cs:line 407
   at GraphQL.Types.GraphTypesLookup.HandleField(IComplexGraphType parentType, FieldType field, TypeCollectionContext context, Boolean applyNameConverter) in C:projectsgraphql-dotnetsrcGraphQLTypesGraphTypesLookup.cs:line 332
   at GraphQL.Types.GraphTypesLookup.AddType(IGraphType type, TypeCollectionContext context) in C:projectsgraphql-dotnetsrcGraphQLTypesGraphTypesLookup.cs:line 246
   at GraphQL.Types.GraphTypesLookup.Create(IEnumerable`1 types, IEnumerable`1 directives, Func`2 resolveType, INameConverter nameConverter, Boolean seal) in C:projectsgraphql-dotnetsrcGraphQLTypesGraphTypesLookup.cs:line 88
   at GraphQL.Types.Schema.CreateTypesLookup() in C:projectsgraphql-dotnetsrcGraphQLTypesSchema.cs:line 311
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
--- End of stack trace from previous location where exception was thrown ---
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.get_Value()
   at GraphQL.Types.Schema.FindType(String name) in C:projectsgraphql-dotnetsrcGraphQLTypesSchema.cs:line 231
   at GraphQL.Types.Schema.Initialize() in C:projectsgraphql-dotnetsrcGraphQLTypesSchema.cs:line 78
   at GraphQL.DocumentExecuter.ExecuteAsync(ExecutionOptions options) in C:projectsgraphql-dotnetsrcGraphQLExecutionDocumentExecuter.cs:line 66
 

Мы настраиваем Startup.cs, как показано ниже

 services.AddSingleton<IDocumentWriter, DocumentWriter>();
        services.AddSingleton<IDocumentExecuter, DocumentExecuter>();
        services.AddSingleton<IDataLoaderContextAccessor, DataLoaderContextAccessor>();
        services.AddSingleton<DataLoaderDocumentListener>();
        services.AddSingleton<ISchema, SchoolSchema>();
        services.AddSingleton<SchoolSchema>();
        services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
        services.AddSingleton<SchoolQuery>();
        services.AddSingleton<SchoolMutation>();
        services.AddSingleton<IHttpHandler,HttpHandler>();
        services.AddSingleton<HttpClient>();

        services.AddScoped<StudentTypeCollection>();
 

Комментарии:

1. та же проблема, вы нашли какое-нибудь решение?