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

core: handle sessions inside target-manager #14106

Merged
merged 2 commits into from
Jun 10, 2022
Merged

core: handle sessions inside target-manager #14106

merged 2 commits into from
Jun 10, 2022

Conversation

brendankenny
Copy link
Member

Improve understandability of target-manager (re: #14078) by moving the sessionattached listener into TargetManager itself. There's no functional change, but this means TargetManager is only in the business of creating FRSessions, not interoperating with them, which opens up further flexibility in the future.

@brendankenny brendankenny requested a review from a team as a code owner June 8, 2022 22:00
@brendankenny brendankenny requested review from adamraine and removed request for a team June 8, 2022 22:00
Comment on lines 93 to 96
/** @type {LH.Puppeteer.CDPSession} */
// @ts-expect-error - temporarily reach in to get CDPSession
const rootCdpSession = this._session._session;
this._targetManager = new TargetManager(rootCdpSession);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a required hack (we need the underlying CdpSession but the FRProtocolSession doesn't include that). A follow up change can move target-manager from inside network-monitor to e.g. driver (and passed in to network-monitor to maintain the current use), so the CdpSession will be readily available then. Cut off here to keep the PR simpler.

/** @type {LH.Puppeteer.CDPSession} */
// @ts-expect-error - temporarily reach in to get CDPSession
const rootCdpSession = this._session._cdpSession;
this._targetManager = new TargetManager(rootCdpSession);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't matter but this code still runs in legacy mode which means this._session._cdpSession will be undefined. We only create a target manager instance, but don't do anything with it which is why everything seems to be working.

@@ -208,16 +208,6 @@ class Driver {
// OOPIF handling in legacy driver is implicit.
}

/** @param {(session: LH.Gatherer.FRProtocolSession) => void} callback */
addSessionAttachedListener(callback) { // eslint-disable-line no-unused-vars
// OOPIF handling in legacy driver is implicit.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the reason these listeners were created was to hide pptr stuff behind the FRProtocolSession abstraction, but since we had to make these methods noops for legacy anyway, I'm fine with this change.

@paulirish paulirish merged commit 4b873ce into master Jun 10, 2022
@paulirish paulirish deleted the tm-cutback branch June 10, 2022 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants