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

handle multiple/duplicate Fetch.requestPaused events #185

Merged
merged 1 commit into from
Dec 19, 2021
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
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