Skip to content

fix(client): correct DoublyLinkedList head removal#3320

Open
abhijeet117 wants to merge 1 commit into
redis:masterfrom
abhijeet117:fix/linked-list-remove-head
Open

fix(client): correct DoublyLinkedList head removal#3320
abhijeet117 wants to merge 1 commit into
redis:masterfrom
abhijeet117:fix/linked-list-remove-head

Conversation

@abhijeet117

@abhijeet117 abhijeet117 commented Jul 6, 2026

Copy link
Copy Markdown

Description

DoublyLinkedList.remove skipped the neighbor pointer fixup whenever the removed node was the head, so the new head kept a stale previous pointer to the removed node. If that head was later removed, tail was set to the already removed node, leaving the list inconsistent and causing following push calls to silently drop values (length reported items that iteration never yielded). This list backs the connection pool, so the corruption could surface there.

The fix sets head and tail from the node's own previous/next links, so both neighbors are always relinked correctly. Added tests cover removing the head and the head-then-tail sequence. Relates to #3062.

Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

Note

Medium Risk
Touches core list logic used by the connection pool and command write queue, but the change is a small, well-tested fix to pointer maintenance rather than new behavior.

Overview
Fixes DoublyLinkedList.remove so removing the head always relinks neighbors instead of only advancing head and skipping pointer fixup on the old head’s successor.

The implementation now uses a single path: splice via previous/next, and set #head or #tail when the removed node is at an end. That clears stale previous on the new head and avoids tail pointing at a detached node after head-then-tail removal (which could make later push values disappear from iteration while length still increased).

Adds unit tests for the new-head previous invariant and for head-then-tail followed by push. The list backs the Redis client connection pool and commands write queue, so this corruption could surface as pool or outbound-command inconsistencies.

Reviewed by Cursor Bugbot for commit 882c26d. Bugbot is set up for automated code reviews on this repo. Configure here.

DoublyLinkedList.remove skipped the neighbor pointer fixup when the
removed node was the head, so the new head kept a stale previous
pointer. A later removal of that head then set tail to the already
removed node, leaving the list inconsistent and causing following push
calls to silently lose data. Update head and tail from the node's own
previous/next links so both neighbors are always fixed up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant