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

[BUG] networkidle while requests in progress #4762

Closed
tuukka opened this issue Dec 18, 2020 · 1 comment
Closed

[BUG] networkidle while requests in progress #4762

tuukka opened this issue Dec 18, 2020 · 1 comment

Comments

@tuukka
Copy link

tuukka commented Dec 18, 2020

Context:

  • Playwright Version: 1.7.0
  • Operating System: Linux
  • Node.js version: 12.19
  • Browser: Chromium

Code Snippet

const { chromium } = require("playwright");

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();

  let inProgress = 0;
  
  page.on('request', request => {
    console.log(Date.now(), '>>', request.method(), request.url());
    inProgress++;
  });
  page.on('response', response => {
    console.log(Date.now(), '<<', response.status(), response.url());
    inProgress--;
  });
  
  console.log(Date.now(), "waiting for page");
  await page.goto("http://localhost:3000/", {
    //    waitUntil: "networkidle",
  });
  
  console.log(Date.now(), "waiting 500");
  await page.waitForTimeout(500);

  console.log(Date.now(), "waiting for networkidle");
  await page.waitForLoadState("networkidle");

  console.log(Date.now(), "Requests in progress after networkidle:", inProgress);

  await browser.close();
})();

Describe the bug

The networkidle event can fire even though requests are in progress (but are taking longer, for example). I would expect the event to fire after 500ms of no requests in progress. (The example script should always finish with inProgress === 0 but doesn't.)

I was not able to reproduce this during page load with waitUntil: "networkidle", so perhaps the logic is different there?

@tuukka
Copy link
Author

tuukka commented Dec 18, 2020

Sorry, found #2515 and this seems to be a duplicate: networkidle is not supposed to wait for requests to finish.

@tuukka tuukka closed this as completed Dec 18, 2020
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

1 participant