Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
check port availability before starting Chromedriver
Browse files Browse the repository at this point in the history
fixes #74
  • Loading branch information
christian-bromann committed Mar 16, 2022
1 parent 39b1dd6 commit 55f73ac
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,10 @@ export default class ChromeDriverLauncher {
log.warn('Falling back to use global chromedriver bin')
command = process && process.platform === 'win32' ? 'chromedriver.exe' : 'chromedriver'
}
this.process = spawn(command, this.args)

if (typeof this.outputDir === 'string') {
this._redirectLogStream()
} else {
this.process.stdout.pipe(split2()).on('data', log.info)
this.process.stderr.pipe(split2()).on('data', log.warn)
}

/**
* wait for port to be available before starting Chromedriver
*/
try {
await tcpPortUsed.waitUntilFree(this.options.port, POLL_INTERVAL, POLL_TIMEOUT)
} catch (err) {
Expand All @@ -83,6 +78,15 @@ export default class ChromeDriverLauncher {
)
}

this.process = spawn(command, this.args)

if (typeof this.outputDir === 'string') {
this._redirectLogStream()
} else {
this.process.stdout.pipe(split2()).on('data', log.info)
this.process.stderr.pipe(split2()).on('data', log.warn)
}

try {
await tcpPortUsed.waitUntilUsed(this.options.port, POLL_INTERVAL, POLL_TIMEOUT)
} catch (err) {
Expand Down

0 comments on commit 55f73ac

Please sign in to comment.