fix(client): dispose credentials subscription on every close() path - #3391
Merged
nkaradzhov merged 1 commit intoAug 5, 2026
Merged
Conversation
nkaradzhov
approved these changes
Aug 5, 2026
nkaradzhov
left a comment
Collaborator
There was a problem hiding this comment.
@lazerg thanks, this looks good to go!
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.
Description
Fixes #3390.
close()only disposed the streaming credentials subscription on the path where the command queue still had pending commands. On a graceful shutdown of an idle client the queue is already empty, soclose()hit the earlyreturn resolve()and left the subscription alive. With@redis/entraidthat keeps the token-refresh timer armed and the process never exits.The dispose call now runs before the empty-queue early return, so both paths release the subscription, matching what
destroy()already does.The new test connects a client with a streaming credentials provider to a mock TCP server, closes it with an empty queue, and asserts the subscription was disposed.
Checklist
npm testpass with this change (including linting)?Note
Low Risk
Small lifecycle fix aligned with
destroy()/quit(); behavior change only affects graceful close with streaming auth when the queue is empty.Overview
close()now disposes the streamingcredentialsSubscriptionat the start of shutdown, before the command-queue empty check. Previously that cleanup only ran on the branch that waited for pending replies, so an idle client could exitclose()without callingdispose()—leaving token-refresh timers alive (e.g. with@redis/entraid) and preventing process exit.A regression test connects with a streaming credentials provider, **
close()**s with an empty queue, and assertsdisposeran.countRespCommandswas hoisted to module scope for shared mock-server use.Reviewed by Cursor Bugbot for commit 1af6ea8. Bugbot is set up for automated code reviews on this repo. Configure here.