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

Network.responseReceivedExtraInfo may be fired before or after responseReceived #120

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ module.exports = {
entriesWithoutPage = [],
responsesWithoutPage = [],
paramsWithoutPage = [],
responseReceivedExtraInfos = [],
currentPageId;

for (const message of messages) {
Expand Down Expand Up @@ -336,11 +337,7 @@ module.exports = {
}

if (!entry) {
debug(
`Received response extra info for requestId ${
params.requestId
} with no matching request.`
);
responseReceivedExtraInfos.push(params);
continue;
}

Expand All @@ -350,13 +347,12 @@ module.exports = {
headers: parseHeaders(params.headers),
blockedCookies: params.blockedCookies
};
responseReceivedExtraInfos.push(params);
continue;
}

if (params.headers) {
entry.response.headers = entry.response.headers.concat(
parseHeaders(params.headers)
);
entry.response.headers = parseHeaders(params.headers);
}
}
break;
Expand Down Expand Up @@ -418,6 +414,19 @@ module.exports = {
);
throw e;
}

const responseReceivedExtraInfo = responseReceivedExtraInfos.find(
responseReceivedExtraInfo =>
responseReceivedExtraInfo.requestId == params.requestId
);
if (
responseReceivedExtraInfo &&
responseReceivedExtraInfo.headers
) {
entry.response.headers = parseHeaders(
responseReceivedExtraInfo.headers
);
}
}
break;

Expand Down
Loading
Loading