FG
🗄️ Databases

ioredis left open handles in Jest

Freshabout 3 years ago
Mar 14, 20260 views
Confidence Score80%
80%

Problem

Hello. 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: [code block] I couldn't find any mentioning of `ioredis` at Jest repo and viceversa. Is there anything that can be done to close connection properly?

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
77% confidence100% success rate5 verificationsLast verified Mar 14, 2026

Solution: ioredis left open handles in Jest

Low Risk

+1 with the issue here, had both `redis.quit()` awaited and `redis.disconnect()` called but nothing :/

77

Trust Score

5 verifications

100% success
  1. 1

    +1 with the issue here, had both `redis.quit()` awaited and `redis.disconnect()`

    +1 with the issue here, had both `redis.quit()` awaited and `redis.disconnect()` called but nothing :/

Validation

Resolved in redis/ioredis GitHub issue #1088. Community reactions: 9 upvotes.

Verification Summary

Worked: 5
Partial: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

redisiorediscache