Skip to content

Commit

Permalink
Merge pull request #263 from YusukeIwaki/porting/8826
Browse files Browse the repository at this point in the history
fix: allow multiple navigations to happen in LifecycleWatcher
  • Loading branch information
YusukeIwaki committed Sep 20, 2022
2 parents 910e217 + c13dd10 commit 2d8b3bd
Showing 1 changed file with 4 additions and 3 deletions.
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

0 comments on commit 2d8b3bd

Please sign in to comment.