{"action":"created","issue":{"url":"https://api.github.com/repos/OpenTl/OpenTl.ClientApi/issues/19","repository_url":"https://api.github.com/repos/OpenTl/OpenTl.ClientApi","labels_url":"https://api.github.com/repos/OpenTl/OpenTl.ClientApi/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/OpenTl/OpenTl.ClientApi/issues/19/comments","events_url":"https://api.github.com/repos/OpenTl/OpenTl.ClientApi/issues/19/events","html_url":"https://github.com/OpenTl/OpenTl.ClientApi/issues/19","id":359052722,"node_id":"MDU6SXNzdWUzNTkwNTI3MjI=","number":19,"title":"Should we register IClientApi as singleton?","user":{"login":"micdenny","id":1633595,"node_id":"MDQ6VXNlcjE2MzM1OTU=","avatar_url":"https://avatars1.githubusercontent.com/u/1633595?v=4","gravatar_id":"","url":"https://api.github.com/users/micdenny","html_url":"https://github.com/micdenny","followers_url":"https://api.github.com/users/micdenny/followers","following_url":"https://api.github.com/users/micdenny/following{/other_user}","gists_url":"https://api.github.com/users/micdenny/gists{/gist_id}","starred_url":"https://api.github.com/users/micdenny/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/micdenny/subscriptions","organizations_url":"https://api.github.com/users/micdenny/orgs","repos_url":"https://api.github.com/users/micdenny/repos","events_url":"https://api.github.com/users/micdenny/events{/privacy}","received_events_url":"https://api.github.com/users/micdenny/received_events","type":"User","site_admin":false},"labels":[{"id":617302975,"node_id":"MDU6TGFiZWw2MTczMDI5NzU=","url":"https://api.github.com/repos/OpenTl/OpenTl.ClientApi/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":{"login":"vik-borisov","id":4207463,"node_id":"MDQ6VXNlcjQyMDc0NjM=","avatar_url":"https://avatars3.githubusercontent.com/u/4207463?v=4","gravatar_id":"","url":"https://api.github.com/users/vik-borisov","html_url":"https://github.com/vik-borisov","followers_url":"https://api.github.com/users/vik-borisov/followers","following_url":"https://api.github.com/users/vik-borisov/following{/other_user}","gists_url":"https://api.github.com/users/vik-borisov/gists{/gist_id}","starred_url":"https://api.github.com/users/vik-borisov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vik-borisov/subscriptions","organizations_url":"https://api.github.com/users/vik-borisov/orgs","repos_url":"https://api.github.com/users/vik-borisov/repos","events_url":"https://api.github.com/users/vik-borisov/events{/privacy}","received_events_url":"https://api.github.com/users/vik-borisov/received_events","type":"User","site_admin":false},"assignees":[{"login":"vik-borisov","id":4207463,"node_id":"MDQ6VXNlcjQyMDc0NjM=","avatar_url":"https://avatars3.githubusercontent.com/u/4207463?v=4","gravatar_id":"","url":"https://api.github.com/users/vik-borisov","html_url":"https://github.com/vik-borisov","followers_url":"https://api.github.com/users/vik-borisov/followers","following_url":"https://api.github.com/users/vik-borisov/following{/other_user}","gists_url":"https://api.github.com/users/vik-borisov/gists{/gist_id}","starred_url":"https://api.github.com/users/vik-borisov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vik-borisov/subscriptions","organizations_url":"https://api.github.com/users/vik-borisov/orgs","repos_url":"https://api.github.com/users/vik-borisov/repos","events_url":"https://api.github.com/users/vik-borisov/events{/privacy}","received_events_url":"https://api.github.com/users/vik-borisov/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2018-09-11T13:40:12Z","updated_at":"2018-10-03T07:48:44Z","closed_at":null,"author_association":"NONE","body":"We are using this server-side and we're getting a lot of these thread-safety errors:\r\n\r\n```\r\nSystem.InvalidOperationException: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.\r\n   at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)\r\n   at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)\r\n   at OpenTl.Schema.Serialization.SerializationMap.TryGetSerializator(TypeInfo type, ISerializator& serializator)\r\n   at OpenTl.Schema.Serialization.SerializationMap.GetSerializator(TypeInfo type)\r\n   at OpenTl.Schema.Serialization.Serializators.ObjectTypes.IObjectSerializer.Deserialize(IByteBuffer buffer, SerializationMetadata typeMetadata)\r\n   at OpenTl.Schema.Serialization.Serializators.ObjectTypes.IObjectSerializer.Deserialize(IByteBuffer buffer, SerializationMetadata typeMetadata)\r\n   at OpenTl.Schema.Serialization.Serializators.ObjectTypes.VectorSerializer.Deserialize(IByteBuffer buffer, SerializationMetadata metadata)\r\n   at OpenTl.Schema.Serialization.Serializators.ObjectTypes.IObjectSerializer.Deserialize(IByteBuffer buffer, SerializationMetadata typeMetadata)\r\n   at OpenTl.ClientApi.MtProto.Layers.Messages.Adapters.RpcResultHandler.ChannelRead0(IChannelHandlerContext ctx, TRpcResult msg)\r\n   at DotNetty.Transport.Channels.SimpleChannelInboundHandler`1.ChannelRead(IChannelHandlerContext ctx, Object msg)\r\n   at DotNetty.Transport.Channels.AbstractChannelHandlerContext.InvokeChannelRead(Object msg)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at OpenTl.ClientApi.MtProto.Services.RequestSenderService.SendRequestAsync[TResult](IRequest`1 request, CancellationToken cancellationToken)\r\n   at OpenTl.ClientApi.Services.ContactsService.ImportContactsAsync(IReadOnlyList`1 contacts, CancellationToken cancellationToken)\r\n```\r\n\r\n```\r\nDotNetty.Codecs.EncoderException: Exception of type 'DotNetty.Codecs.EncoderException' was thrown. ---> System.NullReferenceException: Object reference not set to an instance of an object.\r\n   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)\r\n   at OpenTl.Schema.Serialization.SerializationMap.TryGetSerializator(TypeInfo type, ISerializator& serializator)\r\n   at OpenTl.Schema.Serialization.SerializationMap.GetSerializator(TypeInfo type)\r\n   at OpenTl.Schema.Serialization.Serializer.Serialize(Object obj, IByteBuffer buffer, SerializationMetadata metadata)\r\n   at OpenTl.Schema.Serialization.Serializer.Serialize(Object obj)\r\n   at OpenTl.ClientApi.MtProto.Layers.Secure.Codecs.SecureRequestEncoder.Encode(IChannelHandlerContext context, IObject message, IByteBuffer output)\r\n   at DotNetty.Codecs.MessageToByteEncoder`1.WriteAsync(IChannelHandlerContext context, Object message)\r\n   --- End of inner exception stack trace ---\r\n   at OpenTl.ClientApi.MtProto.Layers.Top.Adapters.TopHandlerAdapter.SendInitConnectionRequest()\r\n   at OpenTl.ClientApi.MtProto.Services.RequestSenderService.SendRequestAsync[TResult](IRequest`1 request, CancellationToken cancellationToken)\r\n   at OpenTl.ClientApi.Services.ContactsService.ImportContactsAsync(IReadOnlyList`1 contacts, CancellationToken cancellationToken)\r\n```\r\n\r\n```\r\nSystem.InvalidOperationException: Collection was modified; enumeration operation may not execute.\r\n   at System.Collections.Generic.LinkedList`1.Enumerator.MoveNext()\r\n   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()\r\n   at OpenTl.ClientApi.MtProto.Layers.Top.Adapters.TopHandlerAdapter.SendInitConnectionRequest()\r\n   at OpenTl.ClientApi.MtProto.Services.RequestSenderService.SendRequestAsync[TResult](IRequest`1 request, CancellationToken cancellationToken)\r\n   at OpenTl.ClientApi.Services.ContactsService.ImportContactsAsync(IReadOnlyList`1 contacts, CancellationToken cancellationToken)\r\n```\r\n\r\nDoes using the `IClientApi` as singleton resolve this thread-safety issues? maybe because some initialization are non thread-safe?"},"comment":{"url":"https://api.github.com/repos/OpenTl/OpenTl.ClientApi/issues/comments/426543177","html_url":"https://github.com/OpenTl/OpenTl.ClientApi/issues/19#issuecomment-426543177","issue_url":"https://api.github.com/repos/OpenTl/OpenTl.ClientApi/issues/19","id":426543177,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNjU0MzE3Nw==","user":{"login":"vik-borisov","id":4207463,"node_id":"MDQ6VXNlcjQyMDc0NjM=","avatar_url":"https://avatars3.githubusercontent.com/u/4207463?v=4","gravatar_id":"","url":"https://api.github.com/users/vik-borisov","html_url":"https://github.com/vik-borisov","followers_url":"https://api.github.com/users/vik-borisov/followers","following_url":"https://api.github.com/users/vik-borisov/following{/other_user}","gists_url":"https://api.github.com/users/vik-borisov/gists{/gist_id}","starred_url":"https://api.github.com/users/vik-borisov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vik-borisov/subscriptions","organizations_url":"https://api.github.com/users/vik-borisov/orgs","repos_url":"https://api.github.com/users/vik-borisov/repos","events_url":"https://api.github.com/users/vik-borisov/events{/privacy}","received_events_url":"https://api.github.com/users/vik-borisov/received_events","type":"User","site_admin":false},"created_at":"2018-10-03T07:48:44Z","updated_at":"2018-10-03T07:48:44Z","author_association":"MEMBER","body":"@micdenny Still relevant?"}}
{"actor":{"display_login":"vik-borisov"}}