Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.IO;
using System.Runtime.ExceptionServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Primitives;

Expand All @@ -33,9 +33,9 @@ public FileConfigurationProvider(FileConfigurationSource source)
{
_changeTokenRegistration = ChangeToken.OnChange(
() => Source.FileProvider.Watch(Source.Path!),
() =>
async () =>
{
Thread.Sleep(Source.ReloadDelay);
Comment thread
tarekgh marked this conversation as resolved.
await Task.Delay(Source.ReloadDelay).ConfigureAwait(false);
Load(reload: true);
});
Comment on lines 34 to 40

@svick svick Jul 10, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the synchronous case, the exception is rethrown in whatever the IFileProvider uses for watching. In case it's PhysicalFilesWatcher, the exception is swallowed anyway.

So I don't think this is a problem.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It holds specifically for PhysicalFilesWatcher (the provider behind  AddJsonFile / AddXmlFile  etc.). A hypothetical custom IFileProvider that invokes token callbacks synchronously and lets exceptions propagate would surface the error in the sync model but not the async one. That is within the async overload's documented contract ("asynchronous exceptions are left unobserved"). I know this is minor issue but is it possible?

}
Expand Down
Loading