-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Conversation
/** @type {LH.Puppeteer.CDPSession} */ | ||
// @ts-expect-error - temporarily reach in to get CDPSession | ||
const rootCdpSession = this._session._session; | ||
this._targetManager = new TargetManager(rootCdpSession); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
Improve understandability of
target-manager
(re: #14078) by moving thesessionattached
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.