Cannot read property 'dropBufferSupport' of undefined
See original GitHub issueHi,
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:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
@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 thethis.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 theset
andget
functions from the module:@alesbolka Thank you! This got me too…