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]: Error: New navigation request was received #8811

Closed
shtse8 opened this issue Aug 18, 2022 · 5 comments · Fixed by #8826 or #8828
Closed

[Bug]: Error: New navigation request was received #8811

shtse8 opened this issue Aug 18, 2022 · 5 comments · Fixed by #8826 or #8828
Assignees

Comments

@shtse8
Copy link

shtse8 commented Aug 18, 2022

Bug description

I can't catch this error and crash my application

new Error('New navigation request was received')

Error: New navigation request was received
    at LifecycleWatcher._LifecycleWatcher_onRequest (D:\project\node_modules\puppeteer\lib\cjs\puppeteer\common\LifecycleWatcher.js:136:139)
    at D:\project\node_modules\puppeteer\lib\cjs\vendor\mitt\src\index.js:51:68
    at Array.map (<anonymous>)
    at Object.emit (D:\project\node_modules\puppeteer\lib\cjs\vendor\mitt\src\index.js:51:43)
    at NetworkManager.emit (D:\project\node_modules\puppeteer\lib\cjs\puppeteer\common\EventEmitter.js:72:22)
    at NetworkManager._NetworkManager_onRequest (D:\project\node_modules\puppeteer\lib\cjs\puppeteer\common\NetworkManager.js:311:10)
    at NetworkManager._NetworkManager_onRequestPaused (D:\project\node_modules\puppeteer\lib\cjs\puppeteer\common\NetworkManager.js:264:97)
    at D:\project\node_modules\puppeteer\lib\cjs\vendor\mitt\src\index.js:51:68
    at Array.map (<anonymous>)
    at Object.emit (D:\project\node_modules\puppeteer\lib\cjs\vendor\mitt\src\index.js:51:43)

I am awaiting goBack while the page is trying to redirect through js with some delay. this error was thrown and crash my application even the catch is wrapped the whole function.

example url: https://healow.com/apps/healow/download.jsp
goback action executes before it redirects

Puppeteer version

puppeteer@16.1.1

Node.js version

18.7

npm version

18.7

What operating system are you seeing the problem on?

Windows

Relevant log output

No response

@shtse8 shtse8 added the bug label Aug 18, 2022
@OrKoN
Copy link
Collaborator

OrKoN commented Aug 18, 2022

@shtse8 could you please provide a minimal script to reproduce? Thanks!

@namma-lux
Copy link

namma-lux commented Aug 21, 2022

await page.goto(SOME_URL);
await page.type('input[name=keywords]', 'hello world');
await Promise.all([
    page.waitForNavigation(),
    page.keyboard.press('Enter'),
]);

It typed the keywords, and redirected after pressing Enter.
Then it threw the error [New navigation request was received].

@shtse8
Copy link
Author

shtse8 commented Aug 21, 2022

@shtse8 could you please provide a minimal script to reproduce? Thanks!

it's hard to reproduce, may need some time to find a best case.
anyway, the point is we can't catch all exception unless we use process.onuncaughtexception.

@OrKoN
Copy link
Collaborator

OrKoN commented Aug 22, 2022

@shtse8 the problem why it fails is that event is not expected from the Puppeteer's perspective and it indicates a bug in Chromium or some unexpected scenario that we don't cover yet. Basically, the crash happens when Puppeteer receives two navigation requests instead of a single expected request. Since it all happens asynchronously there is no error handler for that exception. So a repro would be really helpful here.

@OrKoN OrKoN self-assigned this Aug 22, 2022
@shtse8
Copy link
Author

shtse8 commented Aug 22, 2022

@shtse8 the problem why it fails is that event is not expected from the Puppeteer's perspective and it indicates a bug in Chromium or some unexpected scenario that we don't cover yet. Basically, the crash happens when Puppeteer receives two navigation requests instead of a single expected request. Since it all happens asynchronously there is no error handler for that exception. So a repro would be really helpful here.

Understandable. Since the error goes out of scope so it's hard to be covered by the logic, we also need to catch all uncaught exceptions to prevent app crash. Mostly, evaluating something when the target page is being redirected, which I thought the exception should be thrown from the evaluate so that I can retry the action, but the exception sometimes (not must, that's why hard to reproduce. it needs to happen with a right timing.) go out of scope and crash my application.

OrKoN added a commit that referenced this issue Aug 22, 2022
There is no repro but it looks like sometimes the backend reports
two navigation requests. This PR changes the logic to allow that
instead of failing as it seems that failing is a bigger issue
than handling multiple navigation requests.

Closes #8811
OrKoN added a commit that referenced this issue Aug 22, 2022
There is no repro but it looks like sometimes the backend reports
two navigation requests. This PR changes the logic to allow that
instead of failing as it seems that failing is a bigger issue
than handling multiple navigation requests.

Closes #8811
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants