Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

set the maxeventListener of reverse proxy to avoid warning #428

Closed
wants to merge 3 commits into from
Closed
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
6 changes: 6 additions & 0 deletions lib/node-http-proxy/http-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ var HttpProxy = exports.HttpProxy = function (options) {
? this.enable.xforward
: true;

// if event listener is set then use it else unlimited.
this.eventListenerCount = typeof options.eventListenerCount === 'number'? options.eventListenerCount : 0 ;

//
// Setup additional options for WebSocket proxying. When forcing
// the WebSocket handshake to change the `sec-websocket-location`
Expand Down Expand Up @@ -355,6 +358,9 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
res.on('drain', ondrain);
});

// allow unlimited listeners ...
reverseProxy.setMaxListeners(this.eventListenerCount);

//
// Handle 'error' events from the `reverseProxy`. Setup timeout override if needed
//
Expand Down