binance-api-node icon indicating copy to clipboard operation
binance-api-node copied to clipboard

Even after clean(), it will always return true

Open ngdekhai opened this issue 3 years ago • 1 comments

Hi, I am using version 0.11.40.

In my code, I tried https://github.com/ViewBlock/binance-api-node/issues/470

if(clean) clean(); Even after I cleaned the subscription, the clean still return true. Exclude the initial value of clean, it always return true, even after I run clean(); And fyi clean() successfully stopped the websocket.

How can I be sure that client.ws.ticker or client.ws.futuresUser websocket have stop running?

ngdekhai avatar Oct 13 '22 16:10 ngdekhai

That's up to implementationt atm, but PR's are welcome. In the meantime I've been doing it something like so :

const userMsgHandler = update => {
  if (update.eventType === 'USER_DATA_STREAM_EXPIRED') {
    if (sockets.user.clean && typeof(sockets.user.clean) === 'function') {
      sockets.user.clean()
      delete(sockets.user.clean)
    }
  }
}

const sockets = {
  user: {
    handler: userMsgHandler,
    clean: _ => void, // This isn't used rn
  },
}

sockets.user.clean = api.ws.user(sockets.user.handler)

ubarbaxor avatar Oct 18 '22 07:10 ubarbaxor