Skip to content

Conversation

@hank95179
Copy link
Contributor

Issue link

This Pull Request is linked to issue (URL): #4814

Description

This PR addresses the flakiness observed in the zscan test within node/tests/SharedTests.ts.
The test seeds the database with two sets of data: charMembers (e.g., 'a', 'b', 'c') and members (e.g., 'member 1', 'member 2'...).
The previous assertion strictly required all items returned by zscan to start with "member". However, zscan iterates through the set and may correctly return items from charMembers. When this happened, the strict assertion caused the test to fail incorrectly.

Solution

Updated the assertion logic in runBaseTests.

  • Modified the every check to allow fields that either start with "member" OR are included in the charMembers array.

Verification

Verified that the assertion logic now correctly accounts for all valid data types present in the sorted set, preventing false positive failures.

This change updates the zscan test in SharedTests.ts to allow keys from 'charMembers' (e.g., 'a', 'b', etc.) in the scan results. Previously, the test strictly asserted that all returned keys must start with 'member', causing intermittent failures when 'charMembers' were encountered during scanning (Issue valkey-io#4814).

Signed-off-by: hank95179 <[email protected]>
@hank95179 hank95179 requested a review from a team as a code owner December 14, 2025 04:01
@xShinnRyuu
Copy link
Collaborator

Hi @hank95179 Thanks for contributing

It looks like your solution will fix the issue, but i believe adding match: "member*", is a better solution.

if (!cluster.checkIfServerVersionLessThan("8.0.0")) {
    const result = await client.zscan(key1, initialCursor, {
        match: "member*", // Add in this line so we only retrieve keys starting with "member" and still validate the usage of noScores
        noScores: true,
    });
    const resultCursor = result[resultCursorIndex];
    const fieldsArray = result[
        resultCollectionIndex
    ] as string[];

    // Verify that the cursor is not "0" and values are not included
    expect(resultCursor).not.toEqual("0");
    expect(
        fieldsArray.every((field) =>
            field.startsWith("member"),
        ),
    ).toBeTruthy();
}

@xShinnRyuu
Copy link
Collaborator

Hi @hank95179,

This PR has been open with outstanding feedback. If you could address the comments within the next couple of days, that would be great. Otherwise, I’ll plan to take over the PR and address the issue it was intended to resolve.

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.

2 participants