Repository navigation
Closed
Milestone
Description
Product bug here. FileNotFoundException should not take down the app.
'Microsoft.Extensions.FileProviders.Physical.Tests' from job 7359fb7e-bed2-4677-8025-0794e6d50356 workitem 38c6c2ba-c9ab-42a5-998b-a79c5089ce69 (windows.10.amd64.server19h1.open.rt) executed on machine a0036MX
net6.0-windows-Debug-x86-CoreCLR_release-Windows.10.Amd64.Server19H1.Open
Starting: Microsoft.Extensions.FileProviders.Physical.Tests (parallel test collections = on, max threads = 2)
Unhandled exception. System.IO.FileNotFoundException: Could not find file 'C:\h\w\A9AD08CB\t\ev1xwosb.xvy\igyuv4fj.oko'.
File name: 'C:\h\w\A9AD08CB\t\ev1xwosb.xvy\igyuv4fj.oko'
at System.IO.FileSystem.GetFindData(String fullPath, Boolean isDirectory, Boolean ignoreAccessDenied, WIN32_FIND_DATA& findData) in /_/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Windows.cs:line 219
at System.IO.FileSystem.GetFinalLinkTarget(String linkPath, Boolean isDirectory) in /_/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Windows.cs:line 538
at System.IO.FileSystem.ResolveLinkTarget(String linkPath, Boolean returnFinalTarget, Boolean isDirectory) in /_/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Windows.cs:line 433
at System.IO.FileSystemInfo.ResolveLinkTarget(Boolean returnFinalTarget) in /_/src/libraries/System.Private.CoreLib/src/System/IO/FileSystemInfo.cs:line 170
at Microsoft.Extensions.FileProviders.Physical.FileSystemInfoHelper.GetFileLinkTargetLastWriteTimeUtc(FileInfo fileInfo) in /_/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/Internal/FileSystemInfoHelper.cs:line 54
at Microsoft.Extensions.FileProviders.Physical.PollingFileChangeToken.GetLastWriteTimeUtc() in /_/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PollingFileChangeToken.cs:line 57
at Microsoft.Extensions.FileProviders.Physical.PollingFileChangeToken.get_HasChanged() in /_/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PollingFileChangeToken.cs:line 101
at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.RaiseChangeEvents(Object state) in /_/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs:line 455
at System.Threading.TimerQueueTimer.CallCallback(Boolean isThreadPool) in /_/src/libraries/System.Private.CoreLib/src/System/Threading/Timer.cs:line 712
at System.Threading.TimerQueueTimer.Fire(Boolean isThreadPool) in /_/src/libraries/System.Private.CoreLib/src/System/Threading/Timer.cs:line 673
at System.Threading.TimerQueue.FireNextTimers() in /_/src/libraries/System.Private.CoreLib/src/System/Threading/Timer.cs:line 326
at System.Threading.TimerQueue.AppDomainTimerCallback(Int32 id) in /_/src/coreclr/System.Private.CoreLib/src/System/Threading/Timer.CoreCLR.cs:line 59
----- end Tue 08/10/2021 5:45:17.51 ----- exit code -532462766 ------------
Activity
danmoseley commentedon Aug 10, 2021
This is the new symlink API, but seems a reasonable exception to throw, so we should handle it.
danmoseley commentedon Aug 10, 2021
@adamsitnik is it fragile to run this code on a timer (basically QUWI) and aim to catch only documented exceptions? Since if something wierd happens the app terminates. I wonder whether it should capture all exceptions, like a Task, and rethrow them on the requesting thread? Not sure what the usual pattern is in this code, or whether rethrowing on the original thread would terminate the app anyway.
jozkee commentedon Aug 10, 2021
@danmoseley FWIW I think this happens because
Timer.Dispose()doesn't prevent queued timer callbacks from being called after disposed.We could switch to
Timer.Dispose(WaitHandle)in order to wait for all queued callbacks to finish before continuing disposing and that could prevent the FileNotFoundException, however, PhysicalFileProvider code was already kinda resilient to these errors when used with non-link files so maybe we should go for resiliency instead?ViktorHofer commentedon Aug 11, 2021
FYI in case this is has the same underlying cause: #57221.