WTelegramClient icon indicating copy to clipboard operation
WTelegramClient copied to clipboard

stuck in DownloadFileAsync

Open m0nax3 opened this issue 1 year ago • 1 comments

unfortanly don't have WtClient logs and cant reproduce it isolated . ( big app with thousands connections , lot of threads and async actions and debug logs with primitive static Helpers.log completly useless, I can't separate different WTclients in log)

BUT i have idea, mayby this could help:

when im restart a service, after dispose wtclients with stucked actions i see lot of errors in log errors look like something was UNLOCKed in dispose and trying to do session.save

files are small, few kb - ProfilePhoto without 'big' flag

Message: The object or value could not be serialized. Path: $.
MeatSource: System.Text.Json
TargetSite: Void ReThrowWithPath(System.Text.Json.WriteStack ByRef, System.Exception)
Stack Trace:
   at System.Text.Json.ThrowHelper.ReThrowWithPath(WriteStack& state, Exception ex)
   at System.Text.Json.Serialization.JsonConverter`1.WriteCore(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
   at WTelegram.Session.Save()
   at WTelegram.Client.NewMsgId(Boolean isContent)
   at WTelegram.Client.SendAsync(IObject msg, Boolean isContent, Rpc rpc)
   at WTelegram.Client.Invoke[T](IMethod`1 query)
   at WTelegram.Client.<>c__DisplayClass141_0.<<DownloadFileAsync>g__LoadPart|0>d.MoveNext()
--- End of stack trace from previous location ---
   at WTelegram.Client.DownloadFileAsync(InputFileLocationBase fileLocation, Stream outputStream, Int32 dc_id, Int64 fileSize, ProgressCallback progress)
   at  (APP STACK)
   
    Inner Exception
    ---------------
    Type: System.InvalidOperationException, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
    Message: Cannot write the start of an object or array without a property name. Current token type is 'None'.
    MeatSource: System.Text.Json.Rethrowable
    TargetSite: Void ThrowInvalidOperationException(System.Text.Json.ExceptionResource, Int32, Int32, Byte, System.Text.Json.JsonTokenType)
    Stack Trace:
       at System.Text.Json.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource, Int32 currentDepth, Int32 maxDepth, Byte token, JsonTokenType tokenType)
       at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryWrite(Utf8JsonWriter writer, T value, JsonSerializerOptions options, WriteStack& state)
       at System.Text.Json.Serialization.JsonConverter`1.WriteCore(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)

App hold lot of stuck calls because i ignore them, I make anti-stuck workaround

var limit = Task.Delay(TimeSpan.FromMinutes(1), stoppingToken);                             
var sendTask = //call   wt cliebt                             
Task.WaitAny(sendTask, limit) ;

m0nax3 avatar Sep 21 '24 08:09 m0nax3

Also got hang in DownloadFileAsync... Worked around with time limit + reconnect

vmato avatar Sep 26 '24 01:09 vmato