In the original version, the following operation looks synchronic, however it is not: ``` res.end = end; res.end(data,enc); //emit the log entry ``` In fact, it starts a series of async operations, in which the request may yet be changed after the request log has already been emitted (in our case - a change on request headers was observed, probably by some low level hook or hacky wrap of some http.ServerResponse method that's involved on the process - but called asynchronously) what leads to situation that the request log does not capture valid data. (observed by us: - request headers - calculated end time, when concerning big content ) The fix just used `setTimeout(function() { /*emit the log entry*/ }, 1)`, but I'm afraid it may not hold true for big contents. Well. maybe the headers part will, but the response time calculation will lie. The fix relays on: http://nodejs.org/api/http.html#http_event_finishcdb
parent
176d44833e
commit
cd3971cc03
Loading…
Reference in new issue