question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] add `connection()` to `CDPSession` to maintain parity with Puppeteer

See original GitHub issue

Today I was messing around with the new Lighthouse User Flow api which is written to use puppeteer.

I managed to hack things together to the point where it would work (note I’ve only tried flow.navigate) and one of the things I ran into was the lack of connection() on CDPSession. I’m sure there’s a good reason why it’s not there but for my own sanity I wish it were 😅

The discussion I had with the lighthouse folks has more details on what was required to get things to work

pptr Connection class pptr connection() doc

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
unlikelyzerocommented, Oct 25, 2022

@cliffordfajardo I am not using Lighthouse User Flows. My plan is to use playwright/test to get to interesting points in time and then leverage the lighthouse package as described in https://www.checklyhq.com/learn/headless/basics-performance/#additional-performance-libraries

const chromeLauncher = require('chrome-launcher')
const { chromium } = require('playwright')
const lighthouse = require('lighthouse')
const request = require('request')
const util = require('util')

;(async () => {
  const chrome = await chromeLauncher.launch()

  const resp = await util.promisify(request)(
    `http://localhost:${chrome.port}/json/version`
  )
  const { webSocketDebuggerUrl } = JSON.parse(resp.body)
  const browser = await chromium.connect({ wsEndpoint: webSocketDebuggerUrl })

  const { lhr } = await lighthouse(
    'https://danube-web.shop/',
    { port: chrome.port },
    null
  )

  console.log('Report complete for', lhr.finalUrl)

  console.log(`
    Time To Interactive - Score: ${lhr.audits.interactive.score},
    Value: ${lhr.audits.interactive.numericValue} ${lhr.audits.interactive.numericUnit}
  `)

  await browser.close()
  await chrome.kill()
})()
1reaction
JoelEinbindercommented, Nov 18, 2021

You can launch the browser yourself and connect playwright with connectOverCDP. We don’t want to be in the business of managing CDP connections for you, as they can get very complicated and browser specific.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CDPSession class - Puppeteer
The CDPSession instances are used to talk raw Chrome Devtools Protocol. ... Protocol methods can be called with CDPSession.send() method and protocol events ......
Read more >
Using Chrome Devtools Protocol with Puppeteer
Puppeteer is a high level abstraction over the Chrome Devtools Protocol that gives you a user-friendly API to drive Chromium (or Blink) based...
Read more >
keep open browser in pyppeteer and create CDPSession
connect() function but it seems to be closed imidiately even if I don't call pyppeteer.browser.Browser.close() . test01.py: import asyncio from ...
Read more >
Puppeteer documentation - DevDocs
Indicates that the browser is connected. browser.newPage(). returns: <Promise<Page>>. Promise which resolves to a new Page object. The Page is ...
Read more >
Getting to Know Puppeteer Using Practical Examples
Once it's resolved, we get a browser instance that represents our initialized instance. Connecting Chromium. Sometimes we want to interact with ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found