You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Infinite waiting for resolving waitForLoadState('networkidle') #19835
With waitForLoadState('networkidle') inside the Promise.all, playwright is waiting until timeout even though no request is sent. Noticed it in my app, but I was able to reproduce it with the example page I passed in the code.
Closing since it seems stale and we were not able to reproduce. Please re-file with more information aka. logs which you can set when setting the DEBUG=pw:api,pw:protocol env var.
Also ran into issues with waitLoadState('networkidle') not being fired (using 1.30.0).
But When I run chromium not in headless mode, open the devtools, check the network, then in that case waitLoadState('networkidle') is fired as expected.
Reacted by Peter Holcomb, pawankalyan-greatlearning, Karol Winiarski, Yasha Prikhodko, Mikael Ahabalyants, William S. Takayama and Lance De Waele
Is there any solution for it?
I tried to migrate page.waitForLoadState('networkidle') with other ways to tell if a given page, or action has ended, but there are simply some things that must use it.
in my case
page.waitForLoadState('networkidle')
hangs forever, but only if my api endpoints set the header
Cache-control=no-store
I have not found out yet why this happens, might be custom to my setup.
It either works or more often doesn't, even though all network requests are done, tested from code and from UI network tab.
Removing no-store header did nothing, maybe there's another header blocking but I need this to not depend on headers.
Using this as a replacement:
import{waitForNetworkIdle}from'./waitForNetworkIdle'test('page loads with fetched title',async({page})=>{awaitpage.goto('...')awaitwaitForNetworkIdle(page)// <-consttitle=awaitpage.title()expect(title).toBe('some title')})
import{Page,Request}from'@playwright/test'exportconstwaitForNetworkIdle=async(page: Page,idleTime=500,timeout=10000,): Promise<void>=>{constpending=newSet<Request>()letlastActivity=Date.now()constonRequest=(req: any)=>{pending.add(req)lastActivity=Date.now()}constonDone=(req: any)=>{pending.delete(req)lastActivity=Date.now()}page.on('request',onRequest)page.on('requestfinished',onDone)page.on('requestfailed',onDone)returnnewPromise((resolve,reject)=>{conststart=Date.now()constcheck=()=>{constnow=Date.now()consttimeSinceLastActivity=now-lastActivityif(pending.size===0&&timeSinceLastActivity>=idleTime){cleanup()resolve()}elseif(now-start>timeout){cleanup()reject(newError(`waitForNetworkIdle timed out after ${timeout}ms`))}}constinterval=setInterval(check,100)constcleanup=()=>{clearInterval(interval)page.off('request',onRequest)page.off('requestfinished',onDone)page.off('requestfailed',onDone)}})}
Activity
lyatziv commentedon Jan 3, 2023
This may just be an implementation issue, consider the following change to the code.
mxschmitt commentedon Jan 3, 2023
I tried to run your code and for me it works as expected, it executes successfully.
mxschmitt commentedon Jan 9, 2023
Closing since it seems stale and we were not able to reproduce. Please re-file with more information aka. logs which you can set when setting the
DEBUG=pw:api,pw:protocolenv var.peterholcomb commentedon Jan 31, 2023
FWIW, we are also seeing this in 1.29.2 but were not seeing it in 1.27.1. In some tests, the
waitLoadState('networkidle')seems to never returntonai commentedon Feb 10, 2023
Also ran into issues with
waitLoadState('networkidle')not being fired (using 1.30.0).But When I run chromium not in headless mode, open the devtools, check the network, then in that case
waitLoadState('networkidle')is fired as expected.mxschmitt commentedon Feb 10, 2023
Feel free to file a bug report with a repro, happy to take a look then.
rihaskh commentedon Mar 15, 2023
Still the issue with page.waitForLoadState('networkidle')
rihaskh commentedon Mar 15, 2023
and related this my code ,
await Promise.all([
this.page.waitForLoadState('domcontentloaded'),
this.page.waitForLoadState(),
this.page.waitForResponse(response => response.url().includes('/currentstatuses'), { timeout: 95000 }),
this.page.locator("//button[.='Update']").click(),
]); works well in debugging but when i ran whole script it throws error and close the browser
kwiniarski97 commentedon Mar 24, 2023
Is there any solution for it?
I tried to migrate
page.waitForLoadState('networkidle')with other ways to tell if a given page, or action has ended, but there are simply some things that must use it.creichlin commentedon Sep 11, 2023
in my case
page.waitForLoadState('networkidle')
hangs forever, but only if my api endpoints set the header
Cache-control=no-store
I have not found out yet why this happens, might be custom to my setup.
taschik commentedon Oct 10, 2023
Chris (@creichlin) have you ever found out the reason and a potential fix for your problem?
brutaldev commentedon Jan 13, 2024
A scenario that led me here was using the
SlowMolaunch option which makes it hang on waiting for network idle state 100% of the time.daniel442li commentedon Mar 28, 2024
getting this error too
Radivarig commentedon Mar 29, 2025
It either works or more often doesn't, even though all network requests are done, tested from code and from UI network tab.
Removing
no-storeheader did nothing, maybe there's another header blocking but I need this to not depend on headers.Using this as a replacement:
fix(e2e): replace networkidle with load for Firefox CI stability
docs: update OPTIMIZATION-PLAN with Axeptio/Playwright fix validation
docs: update OPTIMIZATION-PLAN with Axeptio/Playwright fix validation