Skip to content

Commit 8eb6780

Browse files
vinodsrindexzero
authored andcommitted
added option for eventlistenerCount(max)
1 parent 1333c0c commit 8eb6780

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/node-http-proxy/http-proxy.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ var HttpProxy = exports.HttpProxy = function (options) {
103103
? this.enable.xforward
104104
: true;
105105

106+
// if event listener is set then use it else unlimited.
107+
this.eventListenerCount = typeof options.eventListenerCount === 'number'? options.eventListenerCount : 0 ;
108+
106109
//
107110
// Setup additional options for WebSocket proxying. When forcing
108111
// the WebSocket handshake to change the `sec-websocket-location`
@@ -371,10 +374,9 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
371374
res.on('drain', ondrain);
372375
});
373376

374-
375377
// allow unlimited listeners ...
376-
reverseProxy.setMaxListeners(0);
377-
378+
reverseProxy.setMaxListeners(this.eventListenerCount);
379+
378380
//
379381
// Handle 'error' events from the `reverseProxy`. Setup timeout override if needed
380382
//

0 commit comments

Comments
 (0)