-
Notifications
You must be signed in to change notification settings - Fork 7
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
Pass remote debugging port for chrome #39
Conversation
lib/processes.js
Outdated
if (debugPort) { | ||
findOpenPort().then(function (port) { | ||
args.push('--remote-debugging-port=' + port); | ||
config.set('chrome.--remote-debugging-port', port); |
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.
This feels like a weird name for an option. Why not remoteDebuggingPort
?
lib/processes.js
Outdated
@@ -97,6 +97,15 @@ function launchAllProcesses(config) { | |||
args.push('--headless'); | |||
} | |||
if (process.getuid() === 0) args.push('--no-sandbox'); | |||
|
|||
var debugPort = config.get('chrome.--remote-debugging-port'); |
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.
Any reason why this isn't the default? It feels weird that people have to opt-in to enable this feature..?
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.
Did you mean to always pass the port and set in the config? If yes, this was my initial thought -
In most cases, port number won't be used in the tests. Also, I was not very sure that, if we should always set the port even if it would be assigned by chromedriver.
But it makes sense now, if we are exposing API like getPort from testium. We should make it return in consistent way
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.
IIRC there was some chat to just always read it from the port file written by Chrome. Didn't that work out?
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.
@jkrems Unfortunately, that didn't work. Not sure if that was due to system issue (some process errors out writing to hidden directory/files). Looking at chromelauncher code, this option didn't seem bad to me :)
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.
So setting this option is compatible with chromedriver
after all? If so - SGTM. Is there any way we can verify that Chrome has in fact been started with that option?
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.
Some thoughts:
In the future I would hope that we could even get a |
@jkrems What is the best place to add |
I think the "real" implementation should definitely live in |
@jkrems addressed the comments in last commit, except throwing error in the case port is not set. Should we just log the message for the failure case? |
lib/processes.js
Outdated
@@ -97,6 +103,17 @@ function launchAllProcesses(config) { | |||
args.push('--headless'); | |||
} | |||
if (process.getuid() === 0) args.push('--no-sandbox'); | |||
|
|||
var debugPort = config.get('chrome.remoteDebuggingPort', null); |
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.
Since this already runs only when we're using chrome - any reason not to default this to true
instead of null
?
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.
@jkrems This assumes that if the port has been set (with actual value) in .testiumrc, it would address that. Otherwise would discover the new port and update the config.
Are you suggesting that to remove the check and find new port anyway?
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.
Is there value in making the port configurable? That seems to encourage hard-coding values which might lead to problems when running multiple test suites etc..
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.
Oh yes. I didn't think about that. I'll remove the checks
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.
One question, otherwise LGTM
lib/init.js
Outdated
testium = { | ||
close: close, | ||
config: config, | ||
getInitialUrl: getInitialUrl, | ||
getNewPageUrl: _.partial(getNewPageUrl, config.get('proxy.targetUrl')) | ||
getNewPageUrl: _.partial(getNewPageUrl, config.get('proxy.targetUrl')), | ||
getChromeDevtoolsPort: getChromeDevtoolsPort |
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.
nit: it looks like those were sorted alphabetically before.
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.
🎉
Thanks for digging into this & sorry for the long back-and-forth! :) |
@jkrems Thanks for the review :) How do I release new version now? I believe one with 'write access' can do |
These libraries are under nlm, so the new version got released once this got merged! |
Revert "Merge pull request #39 from anil-groupon/pass-debug-port"
Set '--remote-debugging-port' in testium config, which would be consumed by lighthouse to talk with testium.
Line of Thought:
Step 1: [Indidvidual apps] Add flag
--remote-debugging-port
to .testiumrc in the App's repoStep 2: [testium-core] Use this flag to pass to chromedriver/chrome by either directly using the port number or by finding next available port. Also update the testium property, if new port number was used
Step 3: [testium-driver-wd] Add
getPort
method as wd chain methods to fetch the testium propertyStep 4: [Individual apps or itier-accessibility] Port fetch from
browser.getPort
would be used to pass it to lighthouse