[Bug]: Intermittent timeouts when calling WaitForURLAsync
Vandersteen opened this issue · comments
Version
1.41.2
Steps to reproduce
We are getting random "timeout exceptions" when calling WaitForUrlAsync
- We go to a page
- It's expected to be redirected to our identity server
- We log in
- ...
await page.GotoAsync("https://domain.com");
//we expect to be redirected to our identity server
await page.WaitForURLAsync("https://ids.domain.com/Account/Login**");
...
To help us debug, we've added the following to log out the requests:
page.Response += (_, response) =>
{
if (response.Request.IsNavigationRequest)
{
logger.LogInformation(
"{method} {status} {response}",
response.Request.Method,
response.Status,
response.Request.Url
);
}
};
Expected behavior
No random timeouts
Actual behavior
Sometimes it fails without even starting any requests (no logs prior)
=========================== logs ===========================
waiting for navigation to "https://ids.domain.com/Account/Login**" until "Load"
============================================================
---> System.TimeoutException: Timeout 30000ms exceeded.
at Microsoft.Playwright.Helpers.TaskHelper.<>c__DisplayClass2_0.<WithTimeout>b__0() in /_/src/Playwright/Helpers/TaskHelper.cs:line 73
at Microsoft.Playwright.Helpers.TaskHelper.WithTimeout(Task task, Func`1 timeoutAction, TimeSpan timeout, CancellationToken cancellationToken) in /_/src/Playwright/Helpers/TaskHelper.cs:line 109
at Microsoft.Playwright.Core.Waiter.WaitForPromiseAsync[T](Task`1 task, Action dispose) in /_/src/Playwright/Core/Waiter.cs:line 220
--- End of inner exception stack trace ---
at Microsoft.Playwright.Core.Waiter.WaitForPromiseAsync[T](Task`1 task, Action dispose) in /_/src/Playwright/Core/Waiter.cs:line 228
at Microsoft.Playwright.Core.Frame.WaitForNavigationInternalAsync(Waiter waiter, String url, Func`2 urlFunc, Regex urlRegex, String urlString, Nullable`1 waitUntil) in /_/src/Playwright/Core/Frame.cs:line 305
at Microsoft.Playwright.Core.Frame.RunAndWaitForNavigationAsync(Func`1 action, FrameRunAndWaitForNavigationOptions options) in /_/src/Playwright/Core/Frame.cs:line 273
Sometimes it fails while requests have been fired
08:18:09.278 Trace Severity level: Information, Message: GET 200 https://domain.com/app
08:18:11.910 Trace Severity level: Information, Message: GET 302 https://ids.domain.com/connect/authorize?xxxxxxx
08:18:11.986 Trace Severity level: Information, Message: GET 200 https://ids.domain.com/Account/Login?xxxxxxx
08:18:42.172 Exception Call Stack: System.TimeoutException:
at Microsoft.Playwright.Core.Waiter+<WaitForPromiseAsync>d__20`1.MoveNext (Microsoft.Playwright, Version=1.41.2.0, Culture=neutral, PublicKeyToken=db12f80f85d8ba23: /_/src/Playwright/Core/Waiter.cs:228)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Playwright.Core.Frame+<WaitForNavigationInternalAsync>d__49.MoveNext (Microsoft.Playwright, Version=1.41.2.0, Culture=neutral, PublicKeyToken=db12f80f85d8ba23: /_/src/Playwright/Core/Frame.cs:305)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Playwright.Core.Frame+<RunAndWaitForNavigationAsync>d__48.MoveNext (Microsoft.Playwright, Version=1.41.2.0, Culture=neutral, PublicKeyToken=db12f80f85d8ba23: /_/src/Playwright/Core/Frame.cs:273)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at xxxxxx.xxxxxxx+<ExecuteAsync>d__4.MoveNext (xxxxxx, Version=1.2.0.8103, Culture=neutral, PublicKeyToken=null: /src/availability-tests/xxxxxx/xxxxxxx.cs:30)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at xxxxxx.xxxxxxx+<ExecuteAsync>d__4.MoveNext (xxxxxx, Version=1.2.0.8103, Culture=neutral, PublicKeyToken=null: /src/availability-tests/xxxxxx/xxxxxxx.cs:43)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at xxxxxxx.AvailabilityTestsRunner+<>c__DisplayClass8_0+<<RunTestAsync>b__0>d.MoveNext (xxxxxxx, Version=24.1.0.5701, Culture=neutral, PublicKeyToken=null)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Polly.Retry.AsyncRetryEngine+<ImplementationAsync>d__0`1.MoveNext (Polly, Version=8.0.0.0, Culture=neutral, PublicKeyToken=c8a3ffc3f8f825cc)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Polly.AsyncPolicy+<ExecuteAsync>d__21`1.MoveNext (Polly, Version=8.0.0.0, Culture=neutral, PublicKeyToken=c8a3ffc3f8f825cc)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
Inner exception System.TimeoutException handled at Microsoft.Playwright.Core.Waiter+<WaitForPromiseAsync>d__20`1.MoveNext:
at Microsoft.Playwright.Helpers.TaskHelper+<>c__DisplayClass2_0.<WithTimeout>b__0 (Microsoft.Playwright, Version=1.41.2.0, Culture=neutral, PublicKeyToken=db12f80f85d8ba23: /_/src/Playwright/Helpers/TaskHelper.cs:73)
at Microsoft.Playwright.Helpers.TaskHelper+<WithTimeout>d__4.MoveNext (Microsoft.Playwright, Version=1.41.2.0, Culture=neutral, PublicKeyToken=db12f80f85d8ba23: /_/src/Playwright/Helpers/TaskHelper.cs:109)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Playwright.Core.Waiter+<WaitForPromiseAsync>d__20`1.MoveNext (Microsoft.Playwright, Version=1.41.2.0, Culture=neutral, PublicKeyToken=db12f80f85d8ba23: /_/src/Playwright/Core/Waiter.cs:220)
, Message: Timeout 30000ms exceeded.
=========================== logs ===========================
waiting for navigation to "https://ids.domain.com/Account/Login**" until "Load"
============================================================
Additional context
We have added a polly retry policy around this to alleviate this problem as much as possible.
For each "try", the browser is created like this:
using var playwright = await Microsoft.Playwright.Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync();
var page = await browser.NewPageAsync();
In some cases (when there is "clicking" involved), we've managed to reduce / completely remove errors we get by doing:
//seems to reduce the amount of times the error occurs, without this the retry policy needs to kick in often
await Task.WhenAll(
page.WaitForURLAsync("https://domain.com/app**"),
page.ClickAsync("#submit")
);
Environment
- Operating System: [Ubuntu 22.04]
- CPU: [arm64]
- Browser: [Chromium]
- .NET Version (TFM): [net6.0]
- Other info: AKS, 1.27.7
This issue is not following the bug template. Please re-file and provide a self-contained reproduction, which we can run locally to reproduce your issue. Thanks for your understanding!