Skip to content

Commit

Permalink
Network.responseReceivedExtraInfo may be fired before or after respon…
Browse files Browse the repository at this point in the history
…seReceived

From https://chromedevtools.github.io/devtools-protocol/tot/Network/#event-responseReceivedExtraInfo

    responseReceivedExtraInfo may be fired before or after responseReceived.
  • Loading branch information
ifduyue committed Jul 11, 2024
1 parent e1b7c6c commit 2b7eafe
Show file tree
Hide file tree
Showing 3 changed files with 77,041 additions and 8 deletions.
17 changes: 9 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,11 @@ 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

0 comments on commit 2b7eafe

Please sign in to comment.