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

fix(routes): catch route handlers upon respective page closure #23929

Closed
wants to merge 1 commit into from

Conversation

dgozman
Copy link
Contributor

@dgozman dgozman commented Jun 27, 2023

Currently, route handler can throw when page is closed in the middle of it's execution, especially with route.fetch() call inside.

Since you cannot really control when the route hanlder is called, it is hard to handle this situation. However, Playwright can just ignore exceptions in routes after page closure. This would eliminate any potential issues with using Playwright APIs from the route handler.

There is a small chance of unrelated exception being unnoticed in the ignored route handlers, but that seems like small price.

Fixes #23781.

Currently, route handler can throw when page is closed in the middle
of it's execution, especially with `route.fetch()` call inside.

Since you cannot really control when the route hanlder is called,
it is hard to handle this situation. However, Playwright can just
ignore exceptions in routes after page closure. This would eliminate
any potential issues with using Playwright APIs from the route
handler.

There is a small chance of unrelated exception being unnoticed
in the ignored route handlers, but that seems like small price.
@github-actions
Copy link
Contributor

"tests 1" report.

@@ -513,7 +514,12 @@ export class Page extends ChannelOwner<channels.PageChannel> implements api.Page
await this._channel.bringToFront();
}

_shouldCatchAllRouteHandlers() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_shouldCatchAllRouteHandlers() {
_shouldIgnoreAllRouteHandlerExceptions() {

nit: I find catch without context not that meaningful.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd call it _isClosed()

Copy link
Member

@pavelfeldman pavelfeldman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow the rationale here. I understand how fulfill should be silent, but why do we want to mask real errors?

@dgozman dgozman closed this Jun 29, 2023
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

Successfully merging this pull request may close these issues.

[BUG] 'Request context disposed' was reported when use route.fetch()
3 participants