Skip to content

Commit 02f54c6

Browse files
authored
fix(server): Exit clean on unhandledRejections. (#3092)
Add a handler for unhandledRejections, log error and disconnect all, then exit. Also remove broken, untested rejection handler in middleware. Prior to #3064, this block was probably unreachable; the arguments to serveStaticFile are incorrect.
1 parent 0fdd8f9 commit 02f54c6

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

lib/middleware/karma.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,6 @@ function createKarmaMiddleware (
236236
.replace('%MAPPINGS%', mappings)
237237
.replace('\n%X_UA_COMPATIBLE%', getXUACompatibleMetaElement(request.url))
238238
})
239-
}, function (errorFiles) {
240-
serveStaticFile(requestUrl, response, function (data) {
241-
common.setNoCacheHeaders(response)
242-
return data.replace('%SCRIPTS%', '').replace('%CLIENT_CONFIG%', '').replace('%MAPPINGS%',
243-
'window.__karma__.error("TEST RUN WAS CANCELLED because ' +
244-
(errorFiles.length > 1 ? 'these files contain' : 'this file contains') +
245-
' some errors:\\n ' + errorFiles.join('\\n ') + '");')
246-
})
247239
})
248240
} else if (requestUrl === '/context.json') {
249241
return filesPromise.then(function (files) {

lib/server.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,11 @@ class Server extends KarmaEventEmitter {
353353
this.log.error(error)
354354
disconnectBrowsers(1)
355355
})
356+
357+
processWrapper.on('unhandledRejection', (error) => {
358+
this.log.error(error)
359+
disconnectBrowsers(1)
360+
})
356361
}
357362

358363
_detach (config, done) {

0 commit comments

Comments
 (0)