aragon.js icon indicating copy to clipboard operation
aragon.js copied to clipboard

RPC: Potential memory leak from multi-emission subscriptions

Open kernelwhisperer opened this issue 6 years ago • 1 comments

There is no way to unsubscribe after doing sendAndObserveResponses.

For example, sending:

{
      id: 1,
      jsonrpc: '2.0',
      method: 'accounts'
}

will trigger the wrapper to always send updates with id: 1.

I suppose this could be be a common pattern:

onButtonClick () {
  const accounts = await app.accounts.toPromise()
  ...
}

which will make the wrapper send updates for each JSONRPC request, even though the client would expect a one time response.

I can't really find the pub/sub spec :thinking: , but it should be something like this: https://github.com/ethereum/go-ethereum/wiki/RPC-PUB-SUB

kernelwhisperer avatar Dec 26 '18 11:12 kernelwhisperer

One thought on this, we could wrap sendAndObserveResponses() with an endWith, sending a message to the wrapper to also end the stream on its side.

sohkai avatar Jul 10 '19 13:07 sohkai