-
Notifications
You must be signed in to change notification settings - Fork 5k
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.eth.subscribe("newBlockHeaders", null, ...) throws #3159
Comments
@Velenir Thanks for opening and for describing the problem so well. Have opened #3162 to address this. In 1.x web3-eth/src/index.js, re: supportsSubscriptions() As currently written, the result of this method is true when the connection is ws or ipc, and false when http. In turn, There's also ongoing discussion about how ethereum provider features support should really be defined at the EIP 1193 Discussion if you're interested in this topic. |
Thank you for the quick response. Happy to know it's types only which are faulty. re:re: supportsSubscriptions() |
Ok interesting. It works as expected when connecting directly to a local client and have added E2E tests for that in #3165. I think the wallet/injected web3 case gets routed through this given provider logic. That's going to need a closer look. Tbh, there's no community agreement about this interface atm. |
Almost in the given provider. An for version |
Nice! Thanks for finding that. |
The types problem should be fixed on The issue with supportsSubscription looks like it needs to wait for further development of EIP 1193 before it's improved. Closing via #3162 |
Description
Types for
Eth.subscribe
seem to allownull
as the second parameter for all subscriptions:But
web3.eth.subscribe("newBlockHeaders", null, console.log)
breaks withOn the other hand
web3.eth.subscribe("newBlockHeaders", console.log)
, which works as expected, isn't allowed by new types, though it used to be in@types/web3
So either types are wrong, or
subscribe()
function, or both.Expected behavior
Nothing breaks, both
work and allowed by TS
Actual behavior
Uncaught Error: Invalid number of parameters for "null". Got 1 expected 1!
gives
Steps to reproduce the behavior
1.Initialize web3 with a provider
2. Try to subscribe
Error Logs
Gists
https://codesandbox.io/s/withered-surf-y9ccp
(types don't work here though)
Versions
Btw, I can't find
supportsSubscripts
onweb3.currentProvider
inv1.2.2
, but it's there in2.0.0-alpha.1
The text was updated successfully, but these errors were encountered: