-
Notifications
You must be signed in to change notification settings - Fork 11
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
QueueWorker ObjectDisposedException: The CancellationTokenSource has been disposed. #172
Comments
Ohhh damn - I did have this some time ago. The reason was something here (or better: this code is the fix - as some tasks where null): While cancelling (aka in dispose) a lot of things are happening async - so it is not as trivial to reproduce (especially not with an attached debugger). I think this is similar. There might be a still running "something" that waits for something (while in dispose) and tries to access a disposed resource after. Basically, we need a few more safeguards after we awaited some process. I try to have a look on Friday. |
Sadly I can't seem to repro it locally. Fails the build server around once every ten runs. |
Well - your hardware is just too good :D |
Hello, I'm evaluating NCronJob and suffer from this behavior as well. Same kind of issue. Transient and CI only |
By any chance - is there some kind of setup you can share? For example:
|
@linkdotnet Hmmm. Could you please elaborate on that scenario?
Could that trigger a double dispose call at the queue worker level? |
Yeah something like that - I tried to reproduce this with a small test - but no luck so far.
Well, we do have disposables that call other disposables. There might be room for chaos. |
Given the source of your code @nulltoken: public override async Task StopAsync(CancellationToken cancellationToken)
{
if (shutdown != null)
{
await shutdown.CancelAsync();
}
... If public override async Task StopAsync(CancellationToken cancellationToken)
{
if (shutdown is not null && !isDisposed)
{
await shutdown.CancelAsync();
}
... |
Maybe we could push a preview with the given fix above and you (@nulltoken) and @kikisaeba can check? |
This can happen if the Queue manager has been disposed and we waited too long and go into the |
I'd be all in for this |
Oh! Interesting. |
On my side, I've double checked. All tokens are propagated to an eventual HttpClient SendAsync() method. |
Hupps - that should have not been closed. In any case, there will be a preview version out in a second. |
Will do |
Woot! I've run four of five builds against a branch that had a higher ratio of failure (1 every 3 builds on average) and no issue. However, I suggest that we wait until tomorrow before releasing a new stable version
|
@linkdotnet Great job! BTW, you forgot to attribute the fix to its rightful author in the changelog. You deserve all the possible kudos <3 |
Yeah - I also will wait a bit longer. And will also check tomorrow morning for some more spots that might be impacted.
Thanks <3 - will add this once we are certain it fixes the issue. In any case, a new release might be nice given all your hard work and features should be shipped to the public. |
I'll ran a four additional builds, seems stable on my side. |
Describe the bug
While onboarding a new project at $DAYJOB, the CI started to complain
My rough understanding of the call stack is that while xUnit disposes a Collection Fixture, the said collection fixture disposes a Alba hosted test intance of the web app under test, which eventually cascades to NCronJob.
@linkdotnet I have nothing much more than that for now. I'll try to dig a little deeper and report back.
Or otherwise will try to bisect this thing into a minimal repro case (but this may take some time)
Meanwhile, if you've got mind-debugging abilities, I'd be a taker 😉
The text was updated successfully, but these errors were encountered: