ioredis left open handles in Jest
See original GitHub issueHello. I can’t resolve the issue with my Jest tests because of ioredis. Recently I started recieving messages after Jest finished all tests:
A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --runInBand --detectOpenHandles to find leaks.
After a few days of struggling I found the module called leaked-handles, installed it and started debugging. And it seems like both redis.quit()
and redis.disconnect()
not working and connection remains opened after those calls. The error is:
at D:\github\umbress\node_modules\ioredis\built\connectors\StandaloneConnector.js:58:45
tcp stream {
fd: -1,
readable: true,
writable: true,
address: { address: '127.0.0.1', family: 'IPv4', port: 59823 },
serverAddr: null
}
I couldn’t find any mentioning of ioredis
at Jest repo and viceversa. Is there anything that can be done to close connection properly?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:39
- Comments:29 (1 by maintainers)
Top Results From Across the Web
Node.js: Jest + redis.quit() but open handle warning persists
It always throws the "Jest has detected the following 1 open handle potentially keeping Jest from exiting:" error when running with ...
Read more >ioredis causes Jest to not exit after the test run has completed
Jest has detected the following 4 open handles potentially keeping Jest from exiting: ○ Timeout afterEach(async () => redis.flushall()); ...
Read more >Troubleshooting - Jest
Troubleshooting. Uh oh, something went wrong? Use this guide to resolve issues with Jest. Tests are Failing and You Don't Know Why.
Read more >ioredis - npm
A robust, performance-focused and full-featured Redis client for Node.js.. Latest version: 5.2.4, last published: 2 months ago.
Read more >Testing everything against the real database in Nodejs ...
From the monolithic to microservices, the testing pulls out all the ... these are the extensions Jest will look for, in left-to-right order...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
+1 with the issue here, had both
redis.quit()
awaited andredis.disconnect()
called but nothing 😕I’m having a similar issue. I was able to work around it by continually checking the connection status. If it’s not disconnected, just wait 200ms and check again, etc: