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

Redis constructor doesn't parse protocol from host if RedisOptions are passed #1945

Open
Starttoaster opened this issue Jan 13, 2025 · 0 comments

Comments

@Starttoaster
Copy link

Starttoaster commented Jan 13, 2025

This was perhaps just confusing to me from the documentation. But reading Alternatively, specify the connection through a rediss:// URL. from the readme, it seemed intuitive to me that I could declare a client like:

const redis = new Redis({
  host: "rediss://redis.my-service.com",
  port: 6379,
});

And the constructor would parse the protocol rediss:// out from the host string. That appears to not be the case, and only available if specified like:

const redis = new Redis("rediss://redis.my-service.com");

This is probably expected constructor behavior, but wasn't intuitive to me based on the documentation. I would suggest an action item of either:

  1. Update the documentation to say something like Alternatively, specify the connection through a rediss:// URL if not passing RedisOptions.
  2. Change the constructor to parse the protocol out from either mode. It seems like it would be a non-breaking change at least. And makes it less likely that some other dummy like me opens a similar Issue in the future :)
  3. Do nothing, perhaps what I find unintuitive is common sense to everyone else. If this is the option chosen, feel free to close the Issue.

I believe the value in choosing 2 comes with deployment options. It makes it simpler to take pre-existing code that uses the RedisOptions struct (but omits the tls key), and upgrade it to use TLS connections if the proxy in front of your Redis server changes from a TLS-disabled configuration to a TLS-optional one. Say the host string in RedisOptions is set from an environment variable, a person deploying that code could simply change the relevant environment variable to include rediss://, rather than make a pull request to optionally specify tls: {} in their client configuration code.

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

1 participant