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

[Question] proxy.reload: net::ERR_ABORTED #18137

Closed
gajus opened this issue Oct 18, 2022 · 6 comments
Closed

[Question] proxy.reload: net::ERR_ABORTED #18137

gajus opened this issue Oct 18, 2022 · 6 comments

Comments

@gajus
Copy link

gajus commented Oct 18, 2022

I am seeing this happening in our tests:

proxy.reload: net::ERR_ABORTED; maybe frame was detached?
=========================== logs ===========================
waiting for navigation until "networkidle"
============================================================

My theory is that the app is using window.location to change the location, which is somehow causing reload to fail.

The code that's failing is simply:

await page.reload({
  waitUntil: 'networkidle',
});
@dgozman
Copy link
Contributor

dgozman commented Oct 18, 2022

@gajus Your theory seems legit. I'd recommend recording a trace and looking for "navigated to " in the logs around page.reload() to see what's going on.

@gajus
Copy link
Author

gajus commented Oct 18, 2022

That appears to be indeed the case. What's the correct way to handle this?

Do I try..catch reload and retry or is there a better way?

@dgozman
Copy link
Contributor

dgozman commented Oct 18, 2022

Do I try..catch reload and retry or is there a better way?

Depends on what your are trying to achieve. If the page navigates itself, perhaps you could just await page.waitForURL() and let it navigate to the final url? Try/catch and retry is also a fine solution.

@gajus
Copy link
Author

gajus commented Oct 18, 2022

Do I try..catch reload and retry or is there a better way?

Depends on what your are trying to achieve. If the page navigates itself, perhaps you could just await page.waitForURL() and let it navigate to the final url? Try/catch and retry is also a fine solution.

In this case, the intent is to ignore what web app is attempting to do, and take user to a new page.

Prior to adding page.reload(), we had a race condition problem. To illustrate it:

// This methods calls a GraphQL query using `page.evaluate()`
await authenticate(page);

await page.goto('/bar');

await baz();

The intent was to authenticate user and redirect to them to /bar.

However, what happens in practice, the polling mechanism of the app detects that the user was authenticated, and attempts to redirect them to post-login page.

The end result was that sometimes when baz() executes we would be on /home and sometimes on /baz.

The reason for adding page.reload() after authenticate() is to ensure that before we are calling goto there are no more outstanding redirects.

@dgozman
Copy link
Contributor

dgozman commented Oct 18, 2022

I think the easiest would be to let the page redirect to /home, and then navigate to /bar. Something like this:

await authenticate(page);
await page.waitForURL('/home');
await page.goto('/bar');
await baz();

@gajus
Copy link
Author

gajus commented Oct 18, 2022

Where is the facepalm emoji when I need it.

Of course that makes the most sense.

Thanks.

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

2 participants