You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Infinite loop in prettyDOM calls crashes test when locator.element() is not found #7249
the stop condition to the recursion is done by dividing the maxDepth by 2. Considering Infinity / 2 = Infinity, the code enters in a loop and ends up crashing the page.
Reproduction
Found it in private big project (can only be reproduced if the DOM is large enough to enter the result.length >= MAX_LENGTH check. Maybe we can reproduce it by adding a unit test where we send a really small maxDepth and the whole page as object.
Thanks for investigating the issue. Btw, can you share how the error message looks like?
There is no error message. Browser crashes and process wont close. In CI it just hangs until the CI itself times out.
However, I noticed it only happens with expect.element and with following test case instead:
test('should handle large nested DOM timeout',async()=>{letparentDiv=document.createElement("div");letcurrentDiv=parentDiv;for(leti=0;i<20000;i++){constnewDiv=document.createElement("div");currentDiv.appendChild(newDiv);currentDiv=newDiv;}document.body.appendChild(parentDiv);awaitexpect.element(page.getByText("no-such-text")).toBeVisible()});
Activity
tsirlucas commentedon Jan 14, 2025
Im interested in opening a PR for this one, I think we have a few options here:
Considering that we can have another big value instead of Infinity, lets call it
BIG_VALUE_NOT_INFINITYNumber.POSITIVE_INFINITYand instead useBIG_VALUE_NOT_INFINITYBIG_VALUE_NOT_INFINITYhi-ogawa commentedon Jan 15, 2025
Thanks for investigating the issue. Btw, can you share how the error message looks like?
Considering the loop happens due to it goes over
MAX_LENGTH = 10000, the simple repro would be like this. Do you see the same error?tsirlucas commentedon Jan 15, 2025
There is no error message. Browser crashes and process wont close. In CI it just hangs until the CI itself times out.
However, I noticed it only happens with expect.element and with following test case instead:
tsirlucas commentedon Jan 17, 2025
closed in #7250