Skip to content

Commit

Permalink
fix: remove timeout log msg (eggjs#3229)
Browse files Browse the repository at this point in the history
  • Loading branch information
atian25 authored and fengmk2 committed Nov 23, 2018
1 parent de81cae commit 0fb5a96
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
9 changes: 0 additions & 9 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,6 @@ class Application extends EggApplication {
}
}

_onServerTimeout(socket) {
const req = socket.parser.incoming;
if (req) {
this.coreLogger.warn('[http_server] A request `%s %s` timeout with client (%s:%d)', req.method, req.url, socket.remoteAddress, socket.remotePort);
}
socket.destroy();
}

onServer(server) {
// expose app.server
this.server = server;
Expand All @@ -182,7 +174,6 @@ class Application extends EggApplication {

// server timeout
if (is.number(this.config.serverTimeout)) server.setTimeout(this.config.serverTimeout);
server.on('timeout', socket => this._onServerTimeout(socket));
}

/**
Expand Down
15 changes: 15 additions & 0 deletions test/fixtures/apps/app-server-timeout/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

module.exports = app => {
app.messenger.on('egg-ready', () => {
// https://github.com/eggjs/egg/pull/3222
// for general use, alinode will monitor all slow requests so you don't need to log it manually, just for showcase here.
app.server.on('timeout', socket => {
const req = socket.parser.incoming;
if (req && socket._httpMessage) {
app.coreLogger.warn('[http_server] A request `%s %s` timeout with client (%s:%d)', req.method, req.url, socket.remoteAddress, socket.remotePort);
}
socket.destroy();
});
});
};

0 comments on commit 0fb5a96

Please sign in to comment.