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
IOptionsSnapshot can return empty value #37860
Comments
I couldn't figure out the best area label to add to this issue. Please help me learn by adding exactly one area label. |
Thanks for the issue @vladar107, I checked out your sample code and I see that it tries to investigate what happens to IOptionsSnapshot and IOptionsMonitor once a config value changes. As you pointed out in the description, once the config value changes, even though the IOptionsSnapshot value eventually gets updated to its changed value, for scoped and transient (not singleton), we do also see an intermediate empty/null value before it finalizes to its next value set inside config file. It would be good to look at this more closely as the intermediate empty value showing up seems unexpected. |
Hello all. Just in case, I wanted to report the same behavior. I have a service using IOptionsSnapshot to get its settings, but, if you put it under the load, let's say 30+rps and start manually changing the appsettings.json file, you may notice that sometimes the object doesn't contain required settings as if after the appsettings.json update it still tries to load changes you've made even though it's IOptionsSnapshot and should not care during the request. |
Sporadically have the same issue. |
Try to reproduce on .Net 6.0. Can't such behaviour. dotnet --version
6.0.301 Looks like, the issue can be closed. |
I've try to test IOptions and his friends and find some strange behaviour
Simple Web API
With appsetings.json
Controller returns settings value
Client
After start i get next result
After changing settings value
Problems
Why is it empty at first time?
If we compare with IOptionMonitor - on first call it has old value, on second call it has empty value too, and we have third call where value was changed.
Full version of this example here
Environment
The text was updated successfully, but these errors were encountered: