add max limit for dom listner (#2132)

This commit is contained in:
Shuchang Zheng
2025-04-11 19:55:46 -07:00
committed by GitHub
parent 438a49f470
commit 962bf3bc84

View File

@@ -2194,6 +2194,15 @@ function asyncSleepFor(ms) {
}
async function addIncrementalNodeToMap(parentNode, childrenNode) {
const maxParsedElement = 3000;
if ((await window.globalParsedElementCounter.get()) > maxParsedElement) {
console.warn(
"Too many elements parsed, stopping the observer to parse the elements",
);
await window.globalParsedElementCounter.add();
return;
}
// make the dom parser async
await waitForNextFrame();
if (window.globalListnerFlag) {