segment-boneyard / nightmare

A high-level browser automation library.
https://open.segment.com
19.54k stars 1.08k forks source link

Nightmare freezes doing evaluate() #1517

Open jnpatrick99 opened 5 years ago

jnpatrick99 commented 5 years ago

I have the following code

let result = await this.nightmare.evaluate(selector => {
                        return Array.from(document.querySelectorAll(selector))
                            .map(element => element.innerText)
                            .filter((el) => {
                                return el && el != ''
                            });
                    }, 'a');

The page is quite huge, there can be 3000-5000 a tags sometimes. Nightmare freezes when there are around 4000 tags. Before that it doesn't. Sometimes it passes the mark 4500 tags. But after that it freezes again (throws timeout). The memory usage looks fine.

I tried to increase timeout - it didn't help. And I don't think it's the case - when there are less than 4000 tags the evaluate takes about 2 seconds max.

What can be the problem?

scottie commented 5 years ago

I also have the same issue