From 67ce1f924aaee350c04afd70fbae90e3244238a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Kondratiuk?= Date: Fri, 17 May 2024 12:03:41 -0300 Subject: [PATCH 1/3] Expose TaskHelper default timeout (#2635) * Expose TaskHelper default timeout * remove fixed default --- lib/PuppeteerSharp/Helpers/TaskHelper.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/PuppeteerSharp/Helpers/TaskHelper.cs b/lib/PuppeteerSharp/Helpers/TaskHelper.cs index 21965adf3..7a6ecaa01 100644 --- a/lib/PuppeteerSharp/Helpers/TaskHelper.cs +++ b/lib/PuppeteerSharp/Helpers/TaskHelper.cs @@ -9,9 +9,14 @@ namespace PuppeteerSharp.Helpers /// public static class TaskHelper { - private static readonly Func DefaultExceptionFactory = + private static readonly Func _defaultExceptionFactory = timeout => new TimeoutException($"Timeout of {timeout.TotalMilliseconds} ms exceeded"); + /// + /// Default timeout. + /// + public static int DefaultTimeout { get; set; } = 1_000; + // Recipe from https://blogs.msdn.microsoft.com/pfxteam/2012/10/05/how-do-i-cancel-non-cancelable-async-operations/ /// @@ -24,10 +29,10 @@ public static class TaskHelper /// Cancellation token. public static Task WithTimeout( this Task task, - int milliseconds = 1_000, + int? milliseconds = null, Func exceptionFactory = null, CancellationToken cancellationToken = default) - => WithTimeout(task, TimeSpan.FromMilliseconds(milliseconds), exceptionFactory, cancellationToken); + => WithTimeout(task, TimeSpan.FromMilliseconds(milliseconds ?? DefaultTimeout), exceptionFactory, cancellationToken); // Recipe from https://blogs.msdn.microsoft.com/pfxteam/2012/10/05/how-do-i-cancel-non-cancelable-async-operations/ @@ -45,7 +50,7 @@ public static class TaskHelper Func exceptionFactory = null, CancellationToken cancellationToken = default) => task.WithTimeout( - () => throw (exceptionFactory ?? DefaultExceptionFactory)(timeout), + () => throw (exceptionFactory ?? _defaultExceptionFactory)(timeout), timeout, cancellationToken); @@ -155,8 +160,8 @@ public static async Task WithTimeout(this Task task, Action timeoutActi /// Milliseconds timeout. /// Optional timeout exception factory. /// Task return type. - public static Task WithTimeout(this Task task, int milliseconds = 1_000, Func exceptionFactory = null) - => WithTimeout(task, TimeSpan.FromMilliseconds(milliseconds), exceptionFactory); + public static Task WithTimeout(this Task task, int? milliseconds = null, Func exceptionFactory = null) + => WithTimeout(task, TimeSpan.FromMilliseconds(milliseconds ?? DefaultTimeout), exceptionFactory); // Recipe from https://blogs.msdn.microsoft.com/pfxteam/2012/10/05/how-do-i-cancel-non-cancelable-async-operations/ @@ -177,7 +182,7 @@ public static async Task WithTimeout(this Task task, TimeSpan timeout, if (await TimeoutTask(task, timeout).ConfigureAwait(false)) { - throw (exceptionFactory ?? DefaultExceptionFactory)(timeout); + throw (exceptionFactory ?? _defaultExceptionFactory)(timeout); } return await task.ConfigureAwait(false); From c8c8bea940fc17543aecd8f6703d3d1bcabbdf96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Kondratiuk?= Date: Mon, 20 May 2024 14:56:02 -0300 Subject: [PATCH 2/3] v18.1.0 (#2639) --- lib/PuppeteerSharp/PuppeteerSharp.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/PuppeteerSharp/PuppeteerSharp.csproj b/lib/PuppeteerSharp/PuppeteerSharp.csproj index 9374ee3db..715cbb5a9 100644 --- a/lib/PuppeteerSharp/PuppeteerSharp.csproj +++ b/lib/PuppeteerSharp/PuppeteerSharp.csproj @@ -12,10 +12,10 @@ Headless Browser .NET API PuppeteerSharp - 18.0.0 - 18.0.0 - 18.0.0 - 18.0.0 + 18.1.0 + 18.1.0 + 18.1.0 + 18.1.0 false false embedded From 5d6c91c4b76245affda2a4d54ecc8aafb2f95540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Kondratiuk?= Date: Mon, 20 May 2024 16:32:40 -0300 Subject: [PATCH 3/3] v18.0.0 (#2640) v18.0.0 should be there right version --- lib/PuppeteerSharp/PuppeteerSharp.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/PuppeteerSharp/PuppeteerSharp.csproj b/lib/PuppeteerSharp/PuppeteerSharp.csproj index 715cbb5a9..9374ee3db 100644 --- a/lib/PuppeteerSharp/PuppeteerSharp.csproj +++ b/lib/PuppeteerSharp/PuppeteerSharp.csproj @@ -12,10 +12,10 @@ Headless Browser .NET API PuppeteerSharp - 18.1.0 - 18.1.0 - 18.1.0 - 18.1.0 + 18.0.0 + 18.0.0 + 18.0.0 + 18.0.0 false false embedded