resonatecoop / api

The one Resonate API to rule them all
GNU General Public License v3.0
15 stars 5 forks source link

RedisAdapter always opens a connection and does not offer a way to close it #137

Open fgblomqvist opened 2 years ago

fgblomqvist commented 2 years ago

Fiddling around with the tests I kept wondering why mocha kept running forever even though all the cases finished. Any test file that imports from the testConfig keep running forever, even if it just just a expect(true).to.eql(true).

I discovered that testConfig imports the Redis adapter from redis-adapter.js and that that file in turn has a side effect of opening a redis connection, no matter what. Furthermore, there is no way to close that connection since the client sits unexported in the global scope.

There are several issues at play here:

simonv3 commented 2 years ago

I think cleaning up the Redis adapter is a good idea, but I'm not experiencing the issues with mocha keeping on running forever except that watch mode is on by default. How are you running the tests?

fgblomqvist commented 2 years ago

Even with watch mode turned off it happens. I do yarn docker:compose:test:up and then in a separate window yarn test:all. After saying how many passed and skipped it just hangs. Sounds quite odd that our setups are running so differently :thinking:

If I run a single test that does not do any DDB stuff, such as the Template.test.js, and after I've fixed the redis client, that test finishes without issues and mocha exits. But yeah, lots of other oddities. If nothing else, it's fascinating debugging this lol.