aslushnikov / tracium

A blessed Chrome Trace parser.
Apache License 2.0
72 stars 7 forks source link

LHError: NO_NAVSTART when page.goto(file:///Users/path/to/file) #3

Closed mbalabash closed 5 years ago

mbalabash commented 5 years ago

Tracium throws an error when i pass uri to local file in page.goto() of puppeteer. I added PR for this (https://github.com/aslushnikov/tracium/pull/4).

Example of situation:

async function createChromeTrace(urlToHtmlFile, pathToTraceFile, browserOptions) {
  const options = { ...defaultBrowserOptions, ...browserOptions }
  const { headless, emulateNetworkConditions, emulateCpuThrottling } = options

  const browser = await puppeteer.launch({ headless })
  const page = await browser.newPage()
  const client = await page.target().createCDPSession()

  if (emulateNetworkConditions) {
    const { networkConditions } = options
    await client.send('Network.emulateNetworkConditions', networkConditions)
  }

  if (emulateCpuThrottling) {
    const { cpuThrottlingRate } = options
    await client.send('Emulation.setCPUThrottlingRate', { rate: cpuThrottlingRate })
  }

  await page.tracing.start({ path: pathToTraceFile })
  try {
    await page.goto(urlToHtmlFile, { // urlToHtmlFile === file:///Users/mbalabash/Documents/projects/dev/estimo/temp/Fs0UMEq17trTKPUIcgyZj.html
      timeout: options.timeout,
      waitUntil: options.waitUntil,
    })
  } catch (err) {
    handleSessionError(err, browser)
  }
  await page.tracing.stop()

  await browser.close()
  return pathToTraceFile
}
patrickhulce commented 5 years ago

fixed by #4, thanks!