Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth.clearSubscriptions gives error if no running subscriptions do exist #3245

Closed
prographo opened this issue Nov 27, 2019 · 1 comment · Fixed by #3246
Closed

eth.clearSubscriptions gives error if no running subscriptions do exist #3245

prographo opened this issue Nov 27, 2019 · 1 comment · Fixed by #3246
Labels
1.x 1.0 related issues Bug Addressing a bug

Comments

@prographo
Copy link

prographo commented Nov 27, 2019

This call should never give an error.

https://web3js.readthedocs.io/en/v1.2.0/web3-eth-subscribe.html#clearsubscriptions

web3.eth.clearSubscriptions()

Gives this error:

    Object.keys(this.subscriptions).forEach(function(id){
           ^

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)

run this:

const ep = 'wss://goerli.infura.io/ws/v3/<XXX>'
const Web3 = require('web3')
const web3ws = new Web3(
  new Web3.providers.WebsocketProvider( ep )
)
web3ws.eth.clearSubscriptions()
@nivida
Copy link
Contributor

nivida commented Nov 28, 2019

Thanks for opening this issue! This does only happen if no subscription is running.

@nivida nivida added 1.x 1.0 related issues Bug Addressing a bug labels Nov 28, 2019
@nivida nivida changed the title eth.clearSubscriptions gives error eth.clearSubscriptions gives error if no running subscriptions do exist Nov 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x 1.0 related issues Bug Addressing a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants