Skip to content

Commit

Permalink
fix(ci): stop the proxy before killing the child, handle errors (#3472)
Browse files Browse the repository at this point in the history
This should fix #3464, hopefully. Since the test is flaky and only on Travis
we can't be sure until we try for awhile.
  • Loading branch information
johnjbarton authored Apr 13, 2020
1 parent 7b2942c commit abe9af6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
13 changes: 7 additions & 6 deletions test/e2e/step_definitions/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ cucumber.defineSupportCode((a) => {
a.After(function (scenario, callback) {
const running = this.child != null && typeof this.child.kill === 'function'

if (running) {
this.child.kill()
this.child = null
}

// stop the proxy if it was started
this.proxy.stop(callback)
this.proxy.stop(() => {
if (running) {
this.child.kill()
this.child = null
}
callback()
})
})
})
8 changes: 8 additions & 0 deletions test/e2e/support/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ function Proxy () {
target: 'http://localhost:9876'
})

self.proxy.on('error', function proxyError (err, req, res) {
console.log('support/proxy onerror', err)
})

self.server = http.createServer(function (req, res) {
const url = req.url
const match = url.match(self.proxyPathRegExp)
Expand All @@ -22,6 +26,10 @@ function Proxy () {
}
})

self.server.on('clientError', (err, socket) => {
console.log('support/proxy clientError', err)
})

self.start = function (port, proxyPath, callback) {
self.proxyPathRegExp = new RegExp('^' + proxyPath + '(.*)')
self.server.listen(port, function (error) {
Expand Down

0 comments on commit abe9af6

Please sign in to comment.