Closed rvsanten closed 1 year ago
Hi @rvsanten,
Thank you for reporting this important issue. I'll try to resolve the issue asap and keep you posted.
Can confirm having this issue as well. Thanks for working on this issue @tomchavakis . Will follow this issue. Please let me know if I can test something for you.
Hi @dbeusink, @rvsanten Thank you for your message. Can you please run a test to see if the issue has been resolved with the PR code? branch: ftr-tmp-canc
Thank you in advance
Hi @tomchavakis , thank you for your fast resolution. I'm sorry for my late response. The fix works well but the HTTP client will sometimes throw an OperationCanceledException
as well. I've added a suggestion to PR #184.
I also noticed that GetLicenceFromNpkgFile
is also using the HTTP client to make a request without a try/catch. Perhaps we could also apply the same fix to this method to catch a possible timeout exception and log the error.
Inside the same method are some other try/catch clauses for file operations. When an Exception is thrown nothing is logged and the file will be skipped. Perhaps we can also add some logging here? I tried for example to block licenses.nuget.org and the software just silently continued without copying the files.
Thank you for your fast support and I will try to help you out faster next time.
Thanks!
HI @dbeusink , Thank you for your suggestion. Maybe I will ask you to run one more test before merging to master.
@dbeusink, Can you pull the new code and run a test please to confirm that the update is fine? Thank you
Can confirm it's working as expected; both exception types are handled and logged. Log output:
Attempting to download: https://www.nuget.org/api/v2/package/coverlet.collector/3.2.0
Attempting to download https://licenses.nuget.org/MIT to C:\Temp\LicenseOut\coverlet.collector_3.2.0.txt
TaskCanceledException during download of license url https://licenses.nuget.org/MIT exception The operation was canceled.
Attempting to download: https://www.nuget.org/api/v2/package/coverlet.collector/3.2.0
Attempting to download https://licenses.nuget.org/MIT to C:\Temp\LicenseOut\coverlet.collector_3.2.0.txt
TaskCanceledException during download of license url https://licenses.nuget.org/MIT exception The operation was canceled.
Attempting to download: https://www.nuget.org/api/v2/package/fluentassertions/6.9.0
Attempting to download https://licenses.nuget.org/Apache-2.0 to C:\Temp\LicenseOut\FluentAssertions_6.9.0.txt
TaskCanceledException during download of license url https://licenses.nuget.org/Apache-2.0 exception The operation was canceled.
Attempting to download: https://www.nuget.org/api/v2/package/fluentassertions/6.9.0
Attempting to download https://licenses.nuget.org/Apache-2.0 to C:\Temp\LicenseOut\FluentAssertions_6.9.0.txt
TaskCanceledException during download of license url https://licenses.nuget.org/Apache-2.0 exception The operation was canceled.
Attempting to download: https://www.nuget.org/api/v2/package/microsoft.csharp/4.7.0
Attempting to download https://licenses.nuget.org/MIT to C:\Temp\LicenseOut\Microsoft.CSharp_4.7.0.txt
TaskCanceledException during download of license url https://licenses.nuget.org/MIT exception The operation was canceled.
Attempting to download: https://www.nuget.org/api/v2/package/microsoft.csharp/4.7.0
Attempting to download https://licenses.nuget.org/MIT to C:\Temp\LicenseOut\Microsoft.CSharp_4.7.0.txt
TaskCanceledException during download of license url https://licenses.nuget.org/MIT exception The operation was canceled.
Attempting to download: https://www.nuget.org/api/v2/package/microsoft.net.test.sdk/17.4.1
Attempting to download: https://www.nuget.org/api/v2/package/microsoft.tpl.dataflow/4.5.24
Attempting to download http://go.microsoft.com/fwlink/?LinkId=329770 to C:\Temp\LicenseOut\Microsoft.Tpl.Dataflow_4.5.24.txt
TaskCanceledException during download of license url http://go.microsoft.com/fwlink/?LinkId=329770 exception The operation was canceled.
Attempting to download https://raw.githubusercontent.com/moq/moq4/main/License.txt to C:\Temp\LicenseOut\Moq_4.18.4.txt
OperationCanceledException during download of license url https://raw.githubusercontent.com/moq/moq4/main/License.txt exception The operation was canceled.
Attempting to download: https://www.nuget.org/api/v2/package/xunit/2.4.2
Attempting to download https://licenses.nuget.org/Apache-2.0 to C:\Temp\LicenseOut\xunit_2.4.2.txt
TaskCanceledException during download of license url https://licenses.nuget.org/Apache-2.0 exception The operation was canceled.
Attempting to download: https://www.nuget.org/api/v2/package/xunit/2.4.2
Attempting to download https://licenses.nuget.org/Apache-2.0 to C:\Temp\LicenseOut\xunit_2.4.2.txt
TaskCanceledException during download of license url https://licenses.nuget.org/Apache-2.0 exception The operation was canceled.
Attempting to download: https://www.nuget.org/api/v2/package/xunit.runner.visualstudio/2.4.5```
Thank you @dbeusink ,
I will release a new version in order to take advantage of the fix.
Thank you for your support.
Thank you for solving this so quickly, will integrate the new version somewhere next week. And @dbeusink thank you for testing and confirming!
System.Threading.Tasks.TaskCanceledException: The request was canceled due to the configured HttpClient.Timeout of 10 seconds elapsing. ---> System.TimeoutException: A task was canceled. ---> System.Threading.Tasks.TaskCanceledException: A task was canceled. at System.Threading.Tasks.TaskCompletionSourceWithCancellation
1.WaitWithCancellationAsync(CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.GetHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) --- End of inner exception stack trace --- --- End of inner exception stack trace --- at System.Net.Http.HttpClient.HandleFailure(Exception e, Boolean telemetryStarted, HttpResponseMessage response, CancellationTokenSource cts, CancellationToken cancellationToken, CancellationTokenSource pendingRequestsCts) at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at NugetUtility.Methods.ExportLicenseTexts(List
1 infos) in /home/runner/work/nuget-license/nuget-license/src/Methods.cs:line 1013 at NugetUtility.Program.Execute(PackageOptions options) in /home/runner/work/nuget-license/nuget-license/src/Program.cs:line 71See line: https://github.com/tomchavakis/nuget-license/blob/cd15113781151dcce71af304d9ea48508dd8937b/src/Methods.cs#L976
I am using your tool for quite some time now, works great and helps me a lot! But now I ran into a problem that when there is a download timeout (export licenses) the application crashes. It would be nice when the execption is caught and logged. Now our build fails for difficult to troubleshoot error.
try..catch for the ExportLicenseTexts function ->
catch (TimeOutException ex) { WriteOutput($"Problem during download of License url: {fileToDownload} -> {ex.Message}"); }