puppeteer: [Bug]: When I request this website, the browser page gets stuck and cannot be closed.

Minimal, reproducible example

const puppeteer = require('puppeteer');
async function run() {
    const start_time = new Date().getTime()
    const browser = await puppeteer.launch({headless: false, args: ['--auto-open-devtools-for-tabs',]});

    const page = await browser.newPage();
    page.on('response', async (response) => {
        const url = response.url();
        const status = response.status();
        if(status === 200){
            const body = await response.text();
            console.log(`URL: ${url}, Status: ${status}, Body: ${body}`);

        }


    });

    try {
        await page.goto('http://www.zm7.cn/vod/2023-09-23/45578.html', {timeout: 1000});
        const html = await page.content();
    } catch (e) {
        console.log('error')
    }
    console.log("error time", new Date().getTime() - start_time)
    await page.close()
    console.log("page.close()", new Date().getTime() - start_time)
    await browser.close();
}

run()

Error string

The code ‘await page.close()’ is blocked and not executing.

Bug behavior

  • Flaky
  • PDF

Background

output “I intercepted the response and found that the response body is ‘<script src="/_guard/auto.js"></script>’. Is this what you also got?”

Expectation

The code ‘await page.close()’ is executing smoothly.

Reality

The code ‘await page.close()’ is blocked and not executing.

Puppeteer configuration file (if used)

No response

Puppeteer version

21.5.1

Node version

20.7.0

Package manager

npm

Package manager version

10.1.0

Operating system

macOS

About this issue

  • Original URL
  • State: open
  • Created 8 months ago
  • Comments: 25

Most upvoted comments

Looks like the script just enters an infinite loop. Strange that it cannot close the page then. I will file a Chrome bug.