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

fix(cluster): reorder defaults arguments to prioritize user options #889

Merged
merged 1 commit into from
Jun 8, 2019

Conversation

jstewmon
Copy link
Contributor

@jstewmon jstewmon commented Jun 8, 2019

Addresses the issue noted in #883 (comment)

@AVVS
Copy link
Collaborator

AVVS commented Jun 8, 2019

Defaults works the way its intended. From leftmost argument having the highest priority to the rightmost having the least

@jstewmon
Copy link
Contributor Author

jstewmon commented Jun 8, 2019

@AVVS I'm not sure what you meant to express.

Yes, defaults takes the value of a given key from the first argument that defines that key. This particular usage of defaults prioritized the Commander constructor's default options over the user-provided options and the cluster-specific defaults. I added a test to demonstrate why that is problematic (it prevents setting showFriendlyErrorStack).

I've just reordered the arguments so that the priority is:

  1. user-provided options
  2. cluster defaults
  3. Commander defaults

Are you suggesting that the existing behavior is correct and the user should not be able to set any options inherited from Commander?

@AVVS
Copy link
Collaborator

AVVS commented Jun 8, 2019

@jschweik thanks for the details, I did miss that first argument as being passed from the commander, assumed it was from the user input. The change does look good to me now that I've dug into it a little bit more

@AVVS AVVS merged commit 8da8d78 into redis:master Jun 8, 2019
ioredis-robot pushed a commit that referenced this pull request Jun 8, 2019
## [4.10.3](v4.10.2...v4.10.3) (2019-06-08)

### Bug Fixes

* **cluster:** reorder defaults arguments to prioritize user options ([#889](#889)) ([8da8d78](8da8d78))
@ioredis-robot
Copy link
Collaborator

🎉 This PR is included in version 4.10.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@luin
Copy link
Collaborator

luin commented Jun 9, 2019

Good caught! Btw, is there any particular reasons the former this.options assignment is kept?

@jstewmon
Copy link
Contributor Author

jstewmon commented Jun 9, 2019

@luin , no the old assignment should have been removed. I originally commented it out and wrote the new line, so that I could confirm the new test worked as expected, and I accidentally uncommented the old line instead of deleting it. 😞

@jstewmon jstewmon deleted the cluster-options branch June 22, 2019 20:22
janus-dev87 added a commit to janus-dev87/ioredis-work that referenced this pull request Mar 1, 2024
## [4.10.3](redis/ioredis@v4.10.2...v4.10.3) (2019-06-08)

### Bug Fixes

* **cluster:** reorder defaults arguments to prioritize user options ([#889](redis/ioredis#889)) ([8da8d78](redis/ioredis@8da8d78))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants