question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use `redis.createClient` rather than the RedisClient constructor

See original GitHub issue

It’s a bit confusing that we are using the RedisClient constructor directly, as all of the docs (including options) for node_redis are around redis.createClient. Because of this, there is at least one discrepancy with passing connection options to redis. According to current node_redis docs here, the client should be able to specify a url option rather than passing host and port options through the connection hash that you pass through to node_redis. However, the RedisClient constructor does not support a url property. The url property is normalized and split into host and port properties through a call here, which dives into lib/createClient.js and parsed into host and port here. Passing the url option through options.connection in RedisPubSub constructor causes an attempted connection to redis://127.0.0.1:6379, regardless of what is passed via url. Because of this discrepancy, and for the sake of developer sanity, I think it makes more sense to interact with the publicly documented API of node_redis (aka, redis.createClient(options: Object) rather than interface with the RedisClient constructor directly as it fits more inline with the node_redis docs and this lib provides a passthrough via options.connection which will be assumed to follow the node_redis publicly doc’d API. I am willing to put in a PR to make this switch later this week.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mschipperheyncommented, Feb 25, 2019

@thebigredgeek Ah darn. ioredis is still hard coded.

1reaction
davidyahacommented, Dec 13, 2016

@youngboy Just published 1.1.4

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redis redis.createClient() in Typescript - node.js
The option to add a host, port in redis.createClient is no longer supported by redis. So it is not inside type createClient. use...
Read more >
redis.createClient JavaScript and Node.js code examples
How to use. createClient. function. in. redis ... Tabnine vs. ... createClient(secret.port, secret.host) redisClient.auth(secret.password) return ...
Read more >
a node.js redis client - npm
createClient () returns a RedisClient object. Otherwise, createClient() accepts these arguments: redis.
Read more >
Top 5 redis-mock Code Examples - Snyk
Learn more about how to use redis-mock, based on redis-mock code examples created ... createClient(); } else { var Redis = require("ioredis"); redisClient...
Read more >
Node.js databases: using Redis for fun and profit - Medium
Here, instead of exposing a pop function, we expose a constructor for a worker. This constructor receives one function that will be called...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found