Reputation: 1577
I have a backend project written with Sails which connects a model to Redis via sails-redis module.
When trying to run Mocha tests the connection to Redis does not seem to close along with the test-run application and when a test suite is ended and another one begins the new Sails app instance fails to start and I am given the error message:
Error: Connection is already registered at Object.module.exports.adapter.registerConnection (\node_modules\sails-redis\lib\adapter.js:65:54)
I put some breakpoints at some points and checked the redis client list via the CLIENT LIST command from the redis client. I found out that after the Sails app is lowered (shut down peacefully) the connection to Redis remains active:
after(function(done) {
Sails.lower(function () {
done(); // breakpoint was put here. at this point the connection to redis is still persistent although the application has been shut down.
});
});
On the other hand if I run the application via it's normal run command and then close it the connection disappears when the node process is terminated. Has anyone had this kind of trouble? Thanks.
Upvotes: 2
Views: 325