-
Notifications
You must be signed in to change notification settings - Fork 36
Avoid unobserved task exception in AsyncAtomicFactory #686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…oid unobserved task exception when garbage collecting TCS
Thanks for this - I ran the PR build on your change yesterday and your test fails on .NET6 but not Fwk. I started to look but was paged at work so didn't yet get to understand what is wrong. Edit: now I see you pushed more changes - re-running it. |
… as well Remove test in AsyncAtomicFactoryTests again
I suspected that it failed in the first run due to another unobserved task exception from other tests. Indeed, there was the same pattern present in the |
I think your change will break the scenario where two threads are waiting on the same underlying task, there was no test case for this so I added it here: #687 I merged this into your changes so the tests should now run to verify. |
I tried out the scenario using your test - although it is cheesy, I think best approach is to simply await the task to throw the exception inside If you want to merge the await method here with your test and complete this yourself that would be great - I think it is good to have the test running on changes, that way I can't screw it up again. |
Excellent, done. Also logged the actual unobserved task exception so one could see where it came from. |
Thanks for this, merged it. |
Garbage collecting an
AsyncAtomicFactory
instance can cause an unobserved task exception when a value factory threw.This is due to a
TaskCompletionSource.SetException
call in theAsyncAtomicFactory.Initializer
class and its task's exception is never observed.