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

missing error imports #871

Open
SayWut opened this issue Jan 29, 2024 · 0 comments
Open

missing error imports #871

SayWut opened this issue Jan 29, 2024 · 0 comments
Labels
issue: bug report A bug has been reported needs triage

Comments

@SayWut
Copy link

SayWut commented Jan 29, 2024

Describe the bug

My node project is an esm typescript module.
I am trying to catch a timeout error on the page but I unable to find the import of TimeoutError object from puppeteer-extra.
I tried to import if from the puppeteer and puppeteer-core packages but it doesn't recognized as the same object.

Code Snippet

try {
    req = await page.waitForRequest((req) => {
        const checkUrl = /test/g.test(req.url());
        const checkRequestMethod = req.method() === "POST";

        return checkUrl && checkRequestMethod;
    }, {
        timeout: 3000
    });
}
catch (err) {
    if (err instanceof TimeoutError) {
        throw new Error("Some required input fields aren't supported");
    }
}

This is the type of imports that I tried so far but nothing worked:

import { TimeoutError } from "puppeteer-core/lib/esm/puppeteer/common/Errors.js";
import { TimeoutError } from "puppeteer";
import { TimeoutError } from "puppeteer-core";

This is my current work around in the catch

//@ts-ignore
if (err.constructor.name === "TimeoutError") {
    throw new Error("Some required input fields aren't supported");
}

Versions

  System:
    OS: Windows 10 10.0.19045
    CPU: (4) x64 Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
    Memory: 3.32 GB / 15.94 GB
  Binaries:
    Node: 19.9.0 - C:\Program Files\nodejs\node.EXE
    npm: 9.6.3 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    puppeteer: ^21.0.3 => 21.0.3
    puppeteer-extra: ^3.3.6 => 3.3.6
    puppeteer-extra-plugin-adblocker: ^2.13.6 => 2.13.6
    puppeteer-extra-plugin-stealth: ^2.11.2 => 2.11.2
@SayWut SayWut added issue: bug report A bug has been reported needs triage labels Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug report A bug has been reported needs triage
Projects
None yet
Development

No branches or pull requests

1 participant