No error log - app quits (async problem?)
Hey,
I am working on an app that has multiple background workers:
StepOne works correctly, in StepTwo I am calling OpenAI API via this NuGet (https://github.com/OkGoDoIt/OpenAI-API-dotnet).
On this line my app (Console application) just turns off - no error log, nothing.
So I tried doing try-catch block - nothing.
I debugged and figured out problem is here (L133):
https://github.com/OkGoDoIt/OpenAI-API-dotnet/blob/5f7c23a928be39da87e89d5105a044ecb7401727/OpenAI_API/EndpointBase.cs#L133
It's being called with following:
Seems to be correct (calling other endpoint with same NuGet - e.g. chat completion works)
I cloned the repo, put try-catch block around that line - still nothing.
When trying to debug the HttpClient method my debugger is just jumping all around place without sense.
I guess I would have to get the code of HttpClient locally and do it like that - but at that point I am wondering.
Anyone has idea why this is happening? I expect it's because of how I use Tasks?
I am clueless here, not getting any output or error anywhere :/
10 Replies
The reason was in fact using
Task.Run
instead of just putting awaits after each other.
Why though?Also, that
ContinueWith()
...
Can't be sure that is the issue, but
can just be
Yeah, I figured I am doing something wrong the moment I used ContinueWith and had no clue what the 'x' is for
I assume I can pass stuff from prev task?
Yep
Basically,
is the pre-
async
version of
Oh that makes sense.
Thank you 🙂
Do you know why the errors were not logged though?
¯\_(ツ)_/¯
With
async
code, it usually happens when something's fucky-wucky with that, like not awaiting a task or something
But everything seems fine at a glanceYeah, the only thing I changed was the continue with to await and it works now. Fun times
There you go lol
Unfortunately, C# has its fair share of old APIs like that that should not be sued anymore
Non-generic collections,
WebClient
, etc
There's a nice analyzer, BannedSymbolsAnalyzer
I believe it's called, that can help you ban anything you don't want from the codeWill check it out, thank you