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

web3.shh.clearSubscriptions throws TypeError and fails #1466

Closed
dhl opened this issue Mar 16, 2018 · 3 comments · Fixed by #1886
Closed

web3.shh.clearSubscriptions throws TypeError and fails #1466

dhl opened this issue Mar 16, 2018 · 3 comments · Fixed by #1886
Assignees
Labels
Bug Addressing a bug
Projects

Comments

@dhl
Copy link

dhl commented Mar 16, 2018

Calling web3.shh.clearSubscriptions to clear subscriptions fail with a TypeError, with or without any active subscriptions.

System information

web3.js version: 1.0.0-beta.31
Browser Version: Chrome 64.0.3282.186
Commit hash : 956cdc5

Expected behaviour

web3.shh.clearSubscriptions would execute with no error with or without an active subscription.

Actual behaviour

web3.shh.clearSubscriptions fails with a TypeError whether or not an active subscription exists.

TypeError: Cannot convert undefined or null to object

Steps to reproduce the behaviour

A gist was prepared to demonstrate the two failure cases.

See https://gist.github.com/dhl/b463ce9a6bd09e87fe74c992d7958d53

Backtrace

web3-1.0.0-beta.31_clearSubscriptions_bug_demo.html:22 TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at a.u.clearSubscriptions (web3.min.js:1)
    at web3-1.0.0-beta.31_clearSubscriptions_bug_demo.html:19
(anonymous) @ web3-1.0.0-beta.31_clearSubscriptions_bug_demo.html:22

@dhl dhl changed the title web3.shh.clearSubscriptions throws TypeError and fails web3.shh.clearSubscriptions throws TypeError and fails Mar 17, 2018
@ar-to
Copy link

ar-to commented May 21, 2018

I worked around this issue by setting the subscription instance to an object parameter and then I have access to the unsubscribe method.

Ethereum.blockSubscription = web3Socket.eth.subscribe('newBlockHeaders', function (error, sync) {..}

then called it

Ethereum.blockSubscription.unsubscribe(function (error, success) {..}

@semuelle
Copy link
Contributor

semuelle commented Jun 21, 2018

I submitted a pull request with for the shh unsubscribe function. We use that to circumvent the bug you are describing.

var subscription = web3.shh.subscribe("messages", {
   symKeyID: ...,
   topics: ...
})
console.log({"subscription": subscription})
web3.shh.unsubscribe(subscription.id)

@nivida
Copy link
Contributor

nivida commented Jan 22, 2019

This will be fixed within the next release. (PR #2000)

@nivida nivida closed this as completed Jan 22, 2019
1.0 automation moved this from To do to Done Jan 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Addressing a bug
Projects
No open projects
1.0
  
Done
Development

Successfully merging a pull request may close this issue.

4 participants