Skip to content

v4 resubscribe not working #1764

@Redjik

Description

@Redjik

Resubscribe for sub client hangs awaiting Promise.all(promises) in the following part of source code

            const resubscribePromise = this.#queue.resubscribe();
            if (resubscribePromise) {
                promises.push(resubscribePromise);
            }

            if (promises.length) {
                this.#tick(true);
                await Promise.all(promises);
            }

Here's the test code for this:

import {createClient} from "./packages/client";


const pubClient = createClient({
    url: `redis://127.0.0.1:6379`,
    socket: { connectTimeout: 1000 },
})

const subClient = pubClient.duplicate();

pubClient.on('error', (error: Error) => console.error(error));
subClient.on('error', (error: Error) => console.error(error));

pubClient.on('connect', () => console.log('pubClient connected and starting initiator'));
pubClient.on('ready', () => console.log('pubClient is ready'));
subClient.on('connect', () => console.log('subClient connected and starting initiator'));
subClient.on('ready', () => console.log('subClient is ready'));

(async () => {
   await pubClient.connect();
   await subClient.connect();

   subClient.subscribe('some-key', () => {
       console.log('Received');
   });

   setInterval(() => {
       pubClient.publish('some-key', 'data');
       console.log('Sent');
   },  10 * 1000)
})()

So I just run the test script and restart docker container.

Environment:

  • Node.js Version: 12.22.7
  • Redis Server Version: 6.2.6
  • Node Redis Version: 4.0.0
  • Platform: MacOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions