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.

Cannot read property 'dropBufferSupport' of undefined

See original GitHub issue

Hi,
unfortunately I come across this error using ioredis in typescript:

TypeError: Cannot read property 'dropBufferSupport' of undefined at RedisManager.set (/Users/x/Documents/Github/x/backend/node_modules/ioredis/built/commander.js:110:26)

I use a standard setup and a simple test this.client = new Redis({ host: Config.redis.host, port: Config.redis.port, dropBufferSupport: false }); this.client.on('ready', async () => { Logger.info("Redis connected and healthy."); try { await this.set('Test', 'X'); console.log(await this.get('Test')); this.health = true; } catch(err){ console.error(err); } });

Node-Version: 13.10.1 Redis-Version: 5.0.3 ioredis: 4.16.3

Help would be highly appreciated 😃

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
alesbolkacommented, Aug 4, 2020

@JannikSt, From your example I would assume it’s a problem with the way you reference ioredis and use functions - when you use an arrow function, this context is retained from where you defined the this.client.on call. Try using a plain function over an arrow function, those can be bound and called with context supplied to them. Otherwise, a more elaborate example would help. I encountered this problem when trying to build a module interface in a file and just export the set and get functions from the module:

// wrong.js
const cache = new Redis(config);
module.exports = {
  set: cache.set,
  get: cache.get,
};

// working.js
const cache = new Redis(config);
module.exports = {
  set: async (key, value, ttl=30) => cache.set(key, value, 'EX', ttl),
  get: async (key) => cache.get(key),
};

// alternative.js
const cache = new Redis(config);
module.exports = {
  set: cache.set.bind(cache),
  get: cache.get.bind(cache),
};
0reactions
benallfreecommented, Jan 6, 2021

@alesbolka Thank you! This got me too…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read properties of undefined (reading 'createClient ...
But I am getting this error in the word client: The expected type comes from property 'client' which is declared here on type...
Read more >
Cannot read property of undefined? Weird : r/reactjs - Reddit
So, when calling an API, I'm getting an error that it can't read property "en" of undefined. Here is the code: function Coin()...
Read more >
ioredis | Yarn - Package Manager
A robust, performance-focused and full-featured Redis client for Node.js. Supports Redis >= 2.6.12 and (Node.js >= 12.22.0).
Read more >
Changelog - ioredis - Read the Docs
Although the interface doesn't change after upgrading the js parser, there may be still some potential internal differences that may break the applications ......
Read more >
ioredis/Changelog.md - UNPKG
224, Promise doesn't support the `timeout` method. ... 251, * The maxRetriesPerRequest is set to 20 instead of null (same behavior as ioredis...
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