Skip to content

Commit

Permalink
Merge pull request #185 from YusukeIwaki/porting/7802
Browse files Browse the repository at this point in the history
handle multiple/duplicate Fetch.requestPaused events
  • Loading branch information
Yusuke Iwaki committed Dec 19, 2021
2 parents 0425daf + ab910f0 commit dc5c92f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/puppeteer/network_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,24 @@ def request_interception=(enabled)
end

request_id = event['networkId']
return unless request_id

interception_id = event['requestId']
if request_id && (request_will_be_sent_event = @request_id_to_request_with_be_sent_event.delete(request_id))
request_will_be_sent_event = @request_id_to_request_with_be_sent_event[request_id]

# redirect requests have the same `requestId`
if request_will_be_sent_event
if request_will_be_sent_event['request']['url'] != event['request']['url']
request_id_to_request_with_be_sent_event.delete(request_id)
request_will_be_sent_event = nil
end
if request_will_be_sent_event['request']['method'] != event['request']['method']
request_id_to_request_with_be_sent_event.delete(request_id)
request_will_be_sent_event = nil
end
end

if request_will_be_sent_event
handle_request(request_will_be_sent_event, interception_id)
else
@request_id_to_interception_id[request_id] = interception_id
Expand Down

0 comments on commit dc5c92f

Please sign in to comment.