redis icon indicating copy to clipboard operation
redis copied to clipboard

Redis subscribe function takes two args only

Open q8tywolf opened this issue 1 year ago • 1 comments

Package version

9.1

Describe the bug

I get the following error in my code while am following the documentation.

With IORedis

redis.on('message', (channel, messages) => {
  console.log(message)
})

redis.subscribe('user:add', (error, count) => {
  if (error) {
    console.log(error)
  }
})

With AdonisJS

redis.subscribe('user:add', (message) => {
  console.log(message)
},
{
  onError(error) {
    console.log(error)
  },
  onSubscription(count) {
    console.log(count)
  },
})

Expected 2 arguments, but got 3.ts(2554)

        redis.subscribe(`job-application:${entityId}`, (message) => {
            console.log('send message:', message)
        }, {
            onError(error) {
                console.error('Failed to subscribe:', error)
            },
            onSubscription(count) {
                console.log(`Subscribed to ${count} channels.`)
            },
        })

Reproduction repo

No response

q8tywolf avatar Jun 29 '24 13:06 q8tywolf

  • Where does this error come from?
  • Can you please share the complete error stack?

thetutlage avatar Jul 03 '24 04:07 thetutlage

Closing since no answer from issue reporter.

RomainLanz avatar Jan 31 '25 23:01 RomainLanz