Skip to content
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

Timeout on CLS evaluation #120

Open
MehseinJohan opened this issue Apr 20, 2023 · 2 comments
Open

Timeout on CLS evaluation #120

MehseinJohan opened this issue Apr 20, 2023 · 2 comments

Comments

@MehseinJohan
Copy link

Hello team,

When trying to create a PerformanceObserver to log layout-shift entries to the console, as is :

export async function checkCLS2(page, maxLCP=ConstUtils.maxLCP) {
const CLS = await page.evaluate(() => {
return new Promise((resolve) => {
new PerformanceObserver(entryList => {
console.log(entryList.getEntries());
}).observe({ type: "layout-shift", buffered: true });
})
})
expect(CLS).toBeLessThanOrEqual(ConstUtils.maxLCP)
}

I get a timeout. Please note that I'm using the Playwright framework. Do you spot anything I did wrong ?

Many thanks in advance,

Regards,

Johan

@MehseinJohan
Copy link
Author

Hello team,

Could you please provide follow-up on this issue ?

Thank you in advance,

Regards,

Johan

@clelland
Copy link

Hi Johan,

I don't know anything about the framework that you're using (for example, what page.evaluate is expected to do, but it appears that you're creating a promise that never resolves. At least in the section

return new Promise((resolve) => {
    new PerformanceObserver(entryList => {
        console.log(entryList.getEntries());
    }).observe({ type: "layout-shift", buffered: true });
})

I can see that the resolve callback is never going to be called. So even if you do get layout shift entries logged to the console, you will probably get a timeout in your test framework. (That said, I don't know what page.evaluate does, so it's possible that your observer is never even being created. I'd suggest removing that and just trying the PerformanceObserver on its own to start with. Ultimately, anything past that is probably a debugging problem that I can't really help with)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants