Skip to content

Commit

Permalink
fix(server): Exit clean on unhandledRejections.
Browse files Browse the repository at this point in the history
Add a handler for unhandledRejections, log error and disconnect all, then exit.
Also remove broken, untested rejection handler in middleware. Prior to karma-runner#3064,
this block was probably unreachable; the arguments to serveStaticFile are incorrect.
  • Loading branch information
johnjbarton committed Jul 27, 2018
1 parent 88b977f commit 28db86e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
8 changes: 0 additions & 8 deletions lib/middleware/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,6 @@ function createKarmaMiddleware (
.replace('%MAPPINGS%', mappings)
.replace('\n%X_UA_COMPATIBLE%', getXUACompatibleMetaElement(request.url))
})
}, function (errorFiles) {
serveStaticFile(requestUrl, response, function (data) {
common.setNoCacheHeaders(response)
return data.replace('%SCRIPTS%', '').replace('%CLIENT_CONFIG%', '').replace('%MAPPINGS%',
'window.__karma__.error("TEST RUN WAS CANCELLED because ' +
(errorFiles.length > 1 ? 'these files contain' : 'this file contains') +
' some errors:\\n ' + errorFiles.join('\\n ') + '");')
})
})
} else if (requestUrl === '/context.json') {
return filesPromise.then(function (files) {
Expand Down
5 changes: 5 additions & 0 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,11 @@ class Server extends KarmaEventEmitter {
this.log.error(error)
disconnectBrowsers(1)
})

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

_detach (config, done) {
Expand Down

0 comments on commit 28db86e

Please sign in to comment.