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

warning: possible EventEmitter memory leak detected. When user supertest.agent(require(server.js)) #307

Closed
dh376 opened this issue Jan 23, 2016 · 9 comments

Comments

@dh376
Copy link

dh376 commented Jan 23, 2016

The Error Message

(node) warning: possible EventEmitter memory leak detected. 11 connection listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at Server.addListener (events.js:179:15)
at Server._listen2 (/Users/DanHeoFAPL/Desktop/fapl-code/loopback/node_modules/loopback/node_modules/continuation-local-storage/node_modules/async-listener/index.js:65:10)
at listen (net.js:1182:10)
at Server.listen (net.js:1267:5)
at Test.serverAddress (/Users/DanHeoFAPL/Desktop/fapl-code/loopback/node_modules/supertest/lib/test.js:56:33)
at new Test (/Users/DanHeoFAPL/Desktop/fapl-code/loopback/node_modules/supertest/lib/test.js:36:12)
at TestAgent.(anonymous function) as post
at /Users/DanHeoFAPL/Desktop/fapl-code/loopback/test/Dan/helpers/pictorials.js:136:9
at /Users/DanHeoFAPL/Desktop/fapl-code/loopback/node_modules/async/lib/async.js:181:20
at Object.async.forEachOf.async.eachOf (/Users/DanHeoFAPL/Desktop/fapl-code/loopback/node_modules/async/lib/async.js:233:13)

Cause

I'm testing Loopback APIs with mocha and supertest.
To start the server, I do

    server = require('../../server/server.js');
    api = supertest.agent(server);

This is what causes the error.
When I have the server listen to a port and use the port to make api calls, this does not cause the problem. Like this:

server = require('../../server/server.js');
app = server.start()
api = supertest('http://localhost:3000');

There are issues open in async-listner github:
othiym23/async-listener#29
But I only get this when using supertest.agent(server) as I mentioned previously...
This always happens when I try to make multiple api calls with async.each.

@neochrome
Copy link

I had a similar issue when setting up supertest from within the World-constructor in Cucumber.js.
Basically what happend then was an initialization for every scenario across all features which lead to the message about EventEmitter leakage.
My solution to the problem was to move the launching of the server and supertest setup to a pre-all-scenarios hook, which seemed to fix the problem.

@dimitrisfasoulas
Copy link

+1

3 similar comments
@jbroughton72
Copy link

+1

@geoffcorey
Copy link

+1

@dmitrovskiy
Copy link

+1

@tatianacmh
Copy link

I have the same problem, when using supertest or supertest as promised.
I did what you did dh376, and indeed, the annoying warning doesn't appear.

@fredericbarthelet
Copy link

fredericbarthelet commented May 19, 2017

+1
ping @Remy-Luciani

@Remy-Luciani
Copy link

+1

@rimiti rimiti closed this as completed Mar 9, 2019
@luck-arancibia
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests