Skip to content

Commit e4a4dc0

Browse files
committed
fix(ci): stop the proxy before killing the child, handle errors
This should fix #3464, hopefully. Since the test is flaky and only on Travis we can't be sure until we try for awhile.
1 parent 2d206f9 commit e4a4dc0

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

test/e2e/step_definitions/hooks.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ cucumber.defineSupportCode((a) => {
44
a.After(function (scenario, callback) {
55
const running = this.child != null && typeof this.child.kill === 'function'
66

7-
if (running) {
8-
this.child.kill()
9-
this.child = null
10-
}
11-
127
// stop the proxy if it was started
13-
this.proxy.stop(callback)
8+
this.proxy.stop(() => {
9+
if (running) {
10+
this.child.kill()
11+
this.child = null
12+
}
13+
callback()
14+
})
1415
})
1516
})

test/e2e/support/proxy.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ function Proxy () {
99
target: 'http://localhost:9876'
1010
})
1111

12+
self.proxy.on('error', function proxyError (err, req, res) {
13+
console.log('support/proxy onerror', err)
14+
})
15+
1216
self.server = http.createServer(function (req, res) {
1317
const url = req.url
1418
const match = url.match(self.proxyPathRegExp)
@@ -22,6 +26,10 @@ function Proxy () {
2226
}
2327
})
2428

29+
self.server.on('clientError', (err, socket) => {
30+
console.log('support/proxy clientError', err)
31+
})
32+
2533
self.start = function (port, proxyPath, callback) {
2634
self.proxyPathRegExp = new RegExp('^' + proxyPath + '(.*)')
2735
self.server.listen(port, function (error) {

0 commit comments

Comments
 (0)