Skip to content

Commit

Permalink
fix: do not swallow errors from server (#2512)
Browse files Browse the repository at this point in the history
  • Loading branch information
EslamHiko committed Apr 10, 2020
1 parent 0d5c681 commit 06583f2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Server.js
Expand Up @@ -687,6 +687,10 @@ class Server {
} else {
this.listeningApp = http.createServer(this.app);
}

this.listeningApp.on('error', (err) => {
this.log.error(err);
});
}

createSocketServer() {
Expand Down
10 changes: 10 additions & 0 deletions test/server/Server.test.js
Expand Up @@ -76,6 +76,16 @@ describe('Server', () => {
});
});

it('test listeningApp error reporting', () => {
const logMock = jest.fn();
const compiler = webpack(config);
const server = new Server(compiler, baseDevConfig);

server.log.error = logMock;

server.listeningApp.emit('error', new Error('Error !!!'));
expect(server.log.error).toBeCalledWith(new Error('Error !!!'));
});
// issue: https://github.com/webpack/webpack-dev-server/issues/1724
describe('express.static.mine.types', () => {
it("should success even if mine.types doesn't exist", (done) => {
Expand Down

0 comments on commit 06583f2

Please sign in to comment.