2

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 Answers2

5

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

  • hello any help. I'm facing the same issue but in my case am using node js v16 ST, following your solution and yet nothing worked for me what could be the issue my server is running Passenger, Node js (Express) and socket.io with Redis on Centos 7 – OBI PASCAL BANJUARE Mar 06 '22 at 13:18
  • I had the same thing. restarting the terminal after upgrading to node:14 solved the problem. – Nati Kamusher Mar 17 '22 at 17:09
0

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

jony89
  • 5,155
  • 3
  • 30
  • 40