Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Feat: support http server reporting #2512

Merged
merged 1 commit into from
Apr 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/Server.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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