Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in msetArgumentTransformer #1208

Open
NeilASega opened this issue Jan 28, 2023 · 3 comments
Open

Bug in msetArgumentTransformer #1208

NeilASega opened this issue Jan 28, 2023 · 3 comments

Comments

@NeilASega
Copy link

There's a bug in msetArgumentTransformer where it assumes that "typeof object" represents a JS object when arrays also return "object" as their type.

Following update fixes it:

const msetArgumentTransformer = function (args) {
    if (args.length === 1) {
        if (args[0] instanceof Map) {
            return (0, utils_1.convertMapToArray)(args[0]);
        }
        if (typeof args[0] === "object" && args[0] !== null) {
            if (Array.isArray(args[0])) {
                return args[0];
            }
            return (0, utils_1.convertObjectToArray)(args[0]);
        }
    }
    return args;
};

Thanks,
Neil

@NeilASega
Copy link
Author

Having investigated some more, I see that this function is in the "ioredis" module not "ioredis-mock" - so I've opened a new issue here: redis/ioredis#1714

I will close this bug now and hope that "ioredis" devs fix it.

@NeilASega NeilASega reopened this Feb 19, 2023
@NeilASega
Copy link
Author

Unfortunately the problem has yet to be fixed by "ioredis". You can fix in "ioredis-mock" by adding...

args = args.flat();

...in "processArguments" function before calling the Command.transformer. This is essentially what "ioredis" is doing and hence why the bug does not present itself in their module.

@dawsbot
Copy link

dawsbot commented Aug 7, 2023

@NeilASega if this is a widespread issue others might come across perhaps you could add a failing unit test to the codebase so that the discussion is easier to understand? I'm having trouble seeing the issue. It sounds like it also exists in redis itself?

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

No branches or pull requests

2 participants