-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unhandledRejection when waitUntil condition times out in custom command, crashes Nightwatch #4265
Comments
Some extra context I discovered this morning. It seems that the issue occurs when the waitForInProgressOverlay command waitUntil times out and I have a downstream click command with nested .findByText that isn't awaited. // Broken example
await desktopParticipantPage
.click('@coverageMatchLink') // This action triggers a loading screen to appear to "lock" the page
.waitForInProgressOverlay(
500, // Set very short to ensure we timeout to reproduce the issue
'clicked coverage match link in desktop participant page'
)
.click(browser.element.findByText('Ok'))
.assert.textContains('@coverageMatch', 'Covered') // Working example
await desktopParticipantPage
.click('@coverageMatchLink') // This action triggers a loading screen to appear to "lock" the page
.waitForInProgressOverlay(
500, // Set very short to ensure we timeout to reproduce the issue
'clicked coverage match link in desktop participant page'
)
.click(await browser.element.findByText('Ok'))
.assert.textContains('@coverageMatch', 'Covered') |
I tried to reproduce this but I couldn't. Then I realized you are using the custom command on a page object, which clears one thing that this issue is only present for the page objects (although I'm yet to reproduce it, which I'll try in the morning) and the commands work as intended when called on the |
I'll work on it |
@reallymello have you had chance to get a small reproducible test case for us here? |
While its not a end-to-end runnable test case here is an example of a test that failed an assertion and left the browser open and exited early. In red is the before where it was exhibiting the issue and the green was the refactor that allowed the test to fail and teardown normally/close out the browser + session in the post test hook. The underlined line, where the policy holder name is asserted, there was a failure because the element text did not match the test expectation. In the original version these assertions were chained with a downstream click and custom async wait command. When I separated the assertions from those events it failed as expected. While not a full test case I'm hoping this maybe narrows things down. |
Unfortunately, it doesn't narrow it down... We're still struggling to recreate the issue |
@reallymello I tried nearly everything but could not reproduce the issue locally. That said, it would be really helpful if you could provide us with the verbose logs for the sessions where you face this issue, that would give us a good idea what Nightwatch is doing under-the-hood and where things went wrong. Also, you're using the normal Nightwatch test runner and not the Nightwatch Programmatic APIs, right? |
Although we are still not able to reproduce this issue locally, it is anyways a good idea to introduce a null check in that part of the code hoping it could solve part of your problem for now. Created #4278 to add the null checks. |
I emailed verbose logs from 3.8 to @garg3133 |
Description of the bug/issue
When I use waitUntil in an async custom command to wait for an event to occur and that event takes longer than the provided timeout I expect the test to fail gracefully, but instead an unhandledRejection occurs due to the reject property being null causing Nightwatch to exit before ending the session normally (leaving the browser session open).
Steps to reproduce
In general, to reproduce, I have a custom command that uses .waitUntil to wait for a loading panel to complete between postback operations. Sometimes the wait takes longer than the max timeout provided to the waitUntil command which results in an error such as
When this occurs the after/afterEach test hooks and the global session quit never runs. This causes severe issues in our BrowserStack CI runs because it gets interpreted as a timeout and we don't get results for our test run.
Sample test
Command to run
No response
Verbose Output
Nightwatch Configuration
No response
Nightwatch.js Version
3.7
Node Version
20.11
Browser
Chrome 128
Operating System
Windows 11 / Linux
Additional Information
Appears to manifest as a Timeout error when this occurs in BrowserStack TurboScale without any trace information
The text was updated successfully, but these errors were encountered: