I am trying to connect to a Redis server using Typescript and NodeRedis but I am constantly getting this error.
ReferenceError: queueMicrotask is not defined
at RedisClient._RedisClient_tick (/home/administrador/Documentos/node-api-skeleton/node_modules/redis/dist/lib/client.js:378:9)
at RedisSocket.socket_1.default.on.on.on.on (/home/administrador/Documentos/node-api-skeleton/node_modules/redis/dist/lib/client.js:301:86)
at RedisSocket.emit (events.js:198:13)
at RedisSocket.EventEmitter.emit (domain.js:448:20)
at RedisSocket._RedisSocket_connect (/home/administrador/Documentos/node-api-skeleton/node_modules/redis/dist/lib/socket.js:130:10)
at process._tickCallback (internal/process/next_tick.js:68:7)
This the code
const redisClient = createClient();
redisClient.on('error', (err: Error) => {
console.log('Error', err.name);
});
redisClient.on('connect', () =>
console.log('Ok'));
try {
await redisClient.connect();
await redisClient.set(token, email, {
EX: 40,
NX: true,
});
await redisClient.disconnect();
} catch (err) {
console.log('Error', err);
}
Am I missing something?
2
Answers
I've resolved the problem. Somehow my Node Version was 10 and queueMicrotasks are not implemented in that version. I have update Node and now it's working
Could be Node version, yet for me it was actually jest version, so if it happens for you only during tests – make sure to upgrade jest.
bug issue gh: https://github.com/facebook/jest/pull/9140