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

Unable to pass params to Lighthouse when using an external configuration #150

Open
jbelew opened this issue Jan 29, 2018 · 8 comments
Open
Labels

Comments

@jbelew
Copy link

jbelew commented Jan 29, 2018

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
@denar90 denar90 added the bug label Mar 24, 2018
@rsudarson
Copy link

Any update on this issue.

@jbelew
Copy link
Author

jbelew commented May 9, 2018

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.

@santoshjoseph99
Copy link
Contributor

@jbelew Had any luck in setting cookies?

@rsudarson
Copy link

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

@artivilla
Copy link

@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

@chrisrink
Copy link

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.

@artivilla
Copy link

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

@mikehenrty
Copy link

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:

pwmetrics/bin/cli.js

Lines 86 to 87 in f8a784f

// Merge options from all sources. Order indicates precedence (last one wins)
const options = Object.assign({}, {flags: cliFlags}, config);

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants