Async await unlimited callback

the library used is puppeteer,. As soon as you cannot access url, you will get stuck in infinite callback waiting. How to solve this problem

const puppeteer = require("puppeteer-core");

async function test() {
    const browser = await puppeteer.launch({executablePath: "/opt/google/Chromium/chrome"});
    const page = await browser.newPage();
    await page.goto("https://www.baidu/top");
    await page.screenshot({path: "example.png"});

    await browser.close();
};

test().catch(error => console.log(error.message));
Mar.03,2022

catch the timeout exception, because the code made an error in goto , so browser was not closed correctly, causing the nodejs not to end correctly.
so we need to use some methods to ensure that browser can correctly close

.
Menu