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: allow multiple navigations to happen in LifecycleWatcher #263

Merged
merged 1 commit into from Sep 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/puppeteer/lifecycle_watcher.rb
Expand Up @@ -93,13 +93,14 @@ def initialize(frame_manager, frame, wait_until, timeout)
check_lifecycle_complete
end

class AnotherRequestReceivedError < StandardError ; end

# @param [Puppeteer::HTTPRequest] request
def handle_request(request)
return if request.frame != @frame || !request.navigation_request?
@navigation_request = request
@navigation_response_received&.reject(AnotherRequestReceivedError.new('New navigation request was received'))
# Resolve previous navigation response in case there are multiple
# navigation requests reported by the backend. This generally should not
# happen by it looks like it's possible.
@navigation_response_received&.fulfill(nil)
@navigation_response_received = resolvable_future
if request.response && !@navigation_response_received.resolved?
@navigation_response_received.fulfill(nil)
Expand Down