-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix: prevent infinite loop on prettyDOM calls #7250
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
Changes from 5 commits
2605182
f780722
0b13cbf
6be46fe
f815b0a
9b02f20
ed16cda
0841caf
34ff688
7c00ff2
c0b9c08
4e1adfc
e2f36ac
3a343d3
8ee78bc
4d1728d
32a967f
9c2f84d
2189730
3bcb162
69299a2
8f6f9a6
d88b2a1
f10d107
fc4f64a
346c2ef
39bc395
77b8972
1a90e07
0002e1b
891036d
ed80dc4
6307327
90600e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,8 +73,10 @@ export function stringify( | |
| }) | ||
| } | ||
|
|
||
| // Prevents infinite loop https://github.com/vitest-dev/vitest/issues/7249 | ||
| const nextMaxDepth = maxDepth === Infinity ? Number.MAX_SAFE_INTEGER : Math.floor(maxDepth / 2) | ||
|
||
| return result.length >= MAX_LENGTH && maxDepth > 1 | ||
| ? stringify(object, Math.floor(maxDepth / 2)) | ||
| ? stringify(object, nextMaxDepth) | ||
| : result | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { it } from 'vitest'; | ||
|
|
||
| it.skip('fails gracefully when browser crashes', async () => { | ||
|
||
| let parentDiv = document.createElement("div") | ||
|
Check failure on line 4 in test/browser/test/browser-crash.test.ts
|
||
| let currentDiv = parentDiv; | ||
|
|
||
| // Simulate crash by adding a large number of nodes | ||
| for (let i = 0; i < 20000; i++) { | ||
| const newDiv = document.createElement("div") | ||
| currentDiv.appendChild(newDiv) | ||
| currentDiv = newDiv | ||
| } | ||
|
|
||
| document.body.appendChild(parentDiv) | ||
| }) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was making the tests hang #7249 (comment)