Skip to content

Commit

Permalink
synchronous inflight accounting
Browse files Browse the repository at this point in the history
  • Loading branch information
retrohacker committed Mar 14, 2019
1 parent 24d7d8d commit 81000ca
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/server.js
Expand Up @@ -853,11 +853,15 @@ Server.prototype.toString = function toString() {
Server.prototype._onRequest = function _onRequest(req, res) {
var self = this;

// increment number of requests
self._inflightRequests++;

// Give the earliest chain the earliest possible opportunity to process
// this request before we do any work on it
var earliestChain = self.earliestChain;
for (var i = 0; i < earliestChain.length; i++) {
if (earliestChain[i](req, res) === false) {
self._inflightRequests--;
return;
}
}
Expand All @@ -866,15 +870,13 @@ Server.prototype._onRequest = function _onRequest(req, res) {

// Skip Socket.io endpoints
if (this.socketio && /^\/socket\.io.*/.test(req.url)) {
self._inflightRequests--;
return;
}

// Decorate req and res objects
self._setupRequest(req, res);

// increment number of requests
self._inflightRequests++;

// Run in domain to catch async errors
// It has significant negative performance impact
// Warning: this feature depends on the deprecated domains module
Expand Down

0 comments on commit 81000ca

Please sign in to comment.