-
-
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
Infinite loop in prettyDOM calls crashes test when locator.element() is not found #7249
Comments
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
|
Thanks for investigating the issue. Btw, can you share how the error message looks like? Considering the loop happens due to it goes over import { test } from 'vitest'
import { page } from "@vitest/browser/context"
test("repro", () => {
let el = document.createElement("div");
el.textContent = "a".repeat(20000)
document.body.appendChild(el);
page.getByText("no-such-text").element()
})
|
closed in #7250 |
Describe the bug
In
vitest/packages/browser/src/client/tester/public-utils.ts
Line 58 in 345d281
stringify
and invitest/packages/utils/src/display.ts
Line 77 in 345d281
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.System Info
Used Package Manager
yarn
Validations
The text was updated successfully, but these errors were encountered: