pwmetrics icon indicating copy to clipboard operation
pwmetrics copied to clipboard

Unable to pass params to Lighthouse when using an external configuration

Open jbelew opened this issue 7 years ago • 8 comments

Config / CLI options

Steps to reproduce.

Using either combo --

pwmetrics --config --disable-device-emulation
pwmetrics  --disable-device-emulation --config

pwmetrics doesn't pass the parameters to Lighthouse. Same behavior occurs using either JSON or JavaScript configuration files. Without a '--config=' argument, parameters are passed successfully.

Environment

  1. pwmetrics version: 3.1.4
  2. Lighthouse version: 2.8.0

jbelew avatar Jan 29 '18 21:01 jbelew

Any update on this issue.

rsudarson avatar May 05 '18 13:05 rsudarson

Commands aren't documented well, but use the following flags in the config file --

    disableDeviceEmulation: true
    disableNetworkThrottling: true
    disableCpuThrottling: true

Trying to decipher how to set cookies now.

jbelew avatar May 09 '18 21:05 jbelew

@jbelew Had any luck in setting cookies?

santoshjoseph99 avatar Jul 06 '18 06:07 santoshjoseph99

disableStorageReset:True might help. @jbelew Is that correct?

rsudarson avatar Jul 06 '18 06:07 rsudarson

@jbelew @santoshjoseph99 were you able to set your cookies for auth pages and get that to work??

Set up my config something like this but it routes to login:

testURLs.forEach((pageURL) => {
	const pathName = new URL(pageURL).pathname;
	const metric = new PWMetrics(pageURL, {
		flags: {
			// port: 59999,
			logLevel: 'debug',
			runs: 2,
			expectations: false,
			disableCpuThrottling: true,
			disableStorageReset: true,
			// chromeFlags: '--headless',
			json: true,
			outputPath: `perf/metrics${pathName}.json`,
			emulatedFormFactor: 'desktop',
			extraHeaders: {
				Cookie: `JSESSIONID=${process.env.JSESSIONID};CSRFToken=${process.env.CSRFToken};SessionId=${process.env.SessionId}`
			}
		}
	});
	metric.start()
	.then(result => console.log('Perf Run:', result)) // eslint-disable-line no-console
	.catch(e => console.error(e));// eslint-disable-line no-console

artivilla avatar Feb 07 '19 15:02 artivilla

I had a similar issue with trying to login and use an http only cookie. I had a puppeteer script to login first. The trick is that you need to set the flags.disabledStorageReset: true and you need to set the flags.port to the same port that you used for puppeteer. So if you are trying to reuse your session, try doing something like that.

chrisrink avatar Feb 26 '19 17:02 chrisrink

@chrisrink then I don't require having to set cookies through the params. Isn't this a bug then?

artivilla avatar Feb 27 '19 16:02 artivilla

I think maybe the underlying issue is that we expect pwmetrics to merge CLI flags with flags found in the config file. Indeed I believe that was the intention of this code:

https://github.com/paulirish/pwmetrics/blob/f8a784fd6930a1e8b79c1a00e7cd129178638edf/bin/cli.js#L86-L87

However, Object.assign() is not actually merging those flag objects, it's merging the top level object and so cliFlags gets replaced by config.flags.

If indeed the expectation is to merge these flags, it's a bug. I believe it's a relatively straightforward fix, and will submit a PR shortly.

mikehenrty avatar May 30 '20 03:05 mikehenrty