Repository navigation
fix(core): close all named connections on shutdown; consolidate open PRs, 100% coverage and security updates - #311
Merged
Merged
Conversation
RedisCoreModule cleared the shared static token set at the end of the first instance's onApplicationShutdown. With two or more named connections, the remaining instances found an empty set and never quit their clients, leaving open handles (e.g. Jest not exiting). moduleRef.get is strict, so each instance already resolves only its own connection; the set no longer needs to be cleared or pruned. Pruning (as proposed in #307) would still break a second app registering the same connection name, which the new regression test covers. Supersedes #307.
Collect coverage from every source file (not only the ones loaded by a test) and fail below 100% statements, branches, functions and lines. The package test script now runs with --coverage so CI applies the gate. Adds the tests that were missing to reach it: health module/provider wiring, the public API barrel, connections created without options, and connections that do not expose quit().
Consolidates the open Dependabot PRs (#300, #303, #304, #305, #306): - typescript 5.9.3 -> 6.0.3, ts-jest 29.4.6 -> 29.4.14 - @biomejs/biome 2.4.8 -> 2.5.15, turbo 2.8.20 -> 2.11.7 - @nestjs/cli 11.0.16 -> 11.0.24, @nestjs/schematics 11.0.9 -> 11.1.0 Adapts to the TypeScript 6 defaults (strict, esModuleInterop, empty types): the library's emitted declarations are unchanged. Security: refreshes the lockfile and dev dependencies (@nestjs/* 11.2.7, Docusaurus 3.10.2, jest 30.5.2, supertest 7.3.1) and overrides uuid for sockjs. pnpm audit goes from 117 to 2 findings, both without an upstream patch and limited to dev tooling. None affected the published package. Also fixes the single sample, which did not build because it imported ioredis without depending on it.
The package relied on .npmignore, so anything new in the package folder was published. With tests now writing a coverage report, the release job would have shipped coverage/ (including CI runner paths) to npm. Use a files allowlist instead; the tarball keeps the same file list as 2.2.2.
This was referenced Oct 4, 2026
Merged
Member
Author
Remaining
|
| Advisory | Package | Reached through | Exploitable here? |
|---|---|---|---|
| GHSA-vfj7-8cjw-p6xm (high, DoS) | braces ≤ 3.0.3 (latest release) |
jest, chokidar, Docusaurus, @changesets/cli |
No: it needs an attacker-controlled glob pattern; here patterns only come from repo config, and only in dev tooling. |
| GHSA-ch52-4w7c-c8xp (high) | http-cache-semantics ≤ 4.2.0 |
Docusaurus → update-notifier | No: the issue is leaking cached responses between users of a shared HTTP cache; update-notifier is a single-user CLI version check. |
I also tried @changesets/cli 3 (it drops micromatch): changeset version produces the same package.json, but braces stays through jest/Docusaurus and the CHANGELOG indentation changes. Since it doesn't fix the advisory, I left it out of this PR.
Neither package ends up in the published @nestjs-modules/ioredis tarball.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consolidates every open PR into a single change, enforces 100% unit test coverage and clears the open security advisories.
Supersedes #307, #306, #305, #304, #303 and #300.
1. Fix: named connections were never closed on shutdown (from #307)
RedisCoreModulekeeps the connection tokens in a staticSet, but Nest creates one module instance perforRoot/forRootAsyncand callsonApplicationShutdownon each one. The first instance cleared the set after its loop, so the others found it empty and never calledquit()on their clients. The result was open handles (Jest did not exit…), exactly as #307 describes.moduleRef.getis strict by default, so each instance already resolves (and quits) only its own connection. The fix just drops theclear().#307 proposed
delete(token)after each successful quit instead. That still breaks when two apps register the same connection name (the first app to close deletes the token, so the second one skips its connection). The new regression testshould close connections of an app shut down after another onefails with both the current code and the #307 approach, and passes with this one.Verified end to end with the packed package (3 connections:
default,main,sub):2.2.2defaultdefault, main, sub2. 100% coverage, enforced
jest.config.jscollects coverage from every source file (before, files no test imported didn't count) and setscoverageThresholdto 100 for statements, branches, functions and lines.pnpm testruns with--coverage, so CI fails if coverage drops.index.ts), connections created withoutoptions, connections withoutquit(), and the shutdown regressions above.3. Dependencies (Dependabot PRs)
The Dependabot versions were superseded by newer patches in the same lines, so this PR uses the latest in each.
TypeScript 6 changes defaults (
strict,esModuleInterop,types: []):types: ["jest"]and two non-null assertions inredis-options.provider.ts. The emitted.d.tsfiles are identical to TS 5.9's. The only JS change is__importDefault(require("ioredis")), which is equivalent becauseioredisexports itself asdefault.rootDir,types,strictPropertyInitialization: false, drop the deprecatedbaseUrl,import request from 'supertest', and a parameter type inroles.guard.ts.4. Security
pnpm auditmain@nestjs/*11.2.7, Docusaurus 3.10.2, jest 30.5.2, supertest 7.3.1, ts-loader 9.6.2,@changesets/cli^2.31.1.uuid@<11.1.1 → ^11.1.1(pulled in bysockjsviawebpack-dev-server; it only usesv4, which uuid 11 still exports in CJS).http-cache-semantics(Docusaurus → update-notifier) andbraces(@changesets/cli2 → micromatch; it goes away with changesets 3, a major left for a separate PR).@nestjs/terminus..npmignore, so with tests now writingcoverage/the release job would have published it to npm (with runner paths). It now uses"files": ["dist", "CHANGELOG.md"]. The tarball has the same file list as2.2.2.5. Other
singlesample didn't build onmainbecause it importediorediswithout depending on it. Fixed in both samples..gitignore:coverageat any level and*.tsbuildinfo.CLAUDE.mdupdated (shutdown behaviour, coverage, TS 6, overrides).Verification
pnpm check,tsc --noEmit,pnpm build,pnpm test(library + samples) and the sample e2e tests: OKpnpm install --frozen-lockfile: OKdocusaurus build: OK