Skip to content

Commit

Permalink
fix(server): Don't emit infrastructure_failure on ECONNRESET and no s…
Browse files Browse the repository at this point in the history
…ockets open
  • Loading branch information
johnjbarton committed Apr 19, 2019
1 parent 13ed695 commit 3d26799
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions lib/server.js
Expand Up @@ -372,14 +372,32 @@ class Server extends KarmaEventEmitter {
processWrapper.on('SIGINT', () => disconnectBrowsers(process.exitCode))
processWrapper.on('SIGTERM', disconnectBrowsers)

processWrapper.on('uncaughtException', (error) => {
const notKarmaError = (error) => {
// Someone else's socket error?
if (error.toString().includes('ECONNRESET') &&
!Object.keys(socketServer.sockets.sockets).length) {
return true
}
return false
}

const reportError = (error) => {
this.log.error(error)
if (notKarmaError(error)) {
return
}
process.emit('infrastructure_error', error)
disconnectBrowsers(1)
})
}

processWrapper.on('unhandledRejection', (error) => {
this.log.error(error)
disconnectBrowsers(1)
this.log.error('UnhandledRejection')
reportError(error)
})

processWrapper.on('uncaughtException', (error) => {
this.log.error('UncaughtException')
reportError(error)
})
}

Expand Down

0 comments on commit 3d26799

Please sign in to comment.