Skip to content

Commit

Permalink
core: fix main session OOPIF checks for devtools (#12533)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed May 25, 2021
1 parent 3b3df20 commit d882612
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lighthouse-core/lib/network-recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class NetworkRecorder extends EventEmitter {
this._records = [];
/** @type {Map<string, NetworkRequest>} */
this._recordsById = new Map();
/** @type {string|null|undefined} */
this._mainSessionId = null;
}

/**
Expand Down Expand Up @@ -205,6 +207,20 @@ class NetworkRecorder extends EventEmitter {
* @return {NetworkRequest|undefined}
*/
_findRealRequestAndSetSession(requestId, sessionId) {
// The very first sessionId processed is always the main sessionId. In all but DevTools,
// this sessionId is undefined. However, in DevTools the main Lighthouse protocol connection
// does send events with sessionId set to a string, because of how DevTools routes the protocol
// to Lighthouse.
// Many places in Lighthouse use `record.sessionId === undefined` to mean that the session is not
// an OOPIF. To maintain this property, we intercept sessionId here and set it to undefined if
// it matches the first value seen.
if (this._mainSessionId === null) {
this._mainSessionId = sessionId;
}
if (this._mainSessionId === sessionId) {
sessionId = undefined;
}

let request = this._recordsById.get(requestId);
if (!request || !request.isValid) return undefined;

Expand Down

0 comments on commit d882612

Please sign in to comment.