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.eth.getBlockNumber().then(console.log) result is zero #2083

Closed
zyq20130111 opened this issue Nov 30, 2018 · 7 comments
Closed

web3.eth.getBlockNumber().then(console.log) result is zero #2083

zyq20130111 opened this issue Nov 30, 2018 · 7 comments
Labels
Bug Addressing a bug

Comments

@zyq20130111
Copy link

zyq20130111 commented Nov 30, 2018

my code is following:
var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'))
web3.eth.getBlockNumber().then(console.log);

web3.eth.getBlockNumber().then(console.log) this code show zero, but my node sync block number is 4523458 why ??

@nivida nivida added the Bug Addressing a bug label Nov 30, 2018
@nivida
Copy link
Contributor

nivida commented Nov 30, 2018

I've tested it, something is strange with the getBlockNumber method.
I apologize for the troubles.

@Meabo
Copy link

Meabo commented Dec 1, 2018

Hi @zyq20130111 @nivida

I reproduced the following steps:

  • truffle console
  • let Web3 = require('web3')
  • let web3 = new Web3(new Web3(YOUR_INFURA_MAINNET_ENDPOINT))
  • web3.eth.getBlockNumber().then(console.log)
    Output : 6806450

web3 version: web3@1.0.0-beta.36

I think there is no issue here. Only need to upgrade your web3 version.

@nivida
Copy link
Contributor

nivida commented Dec 1, 2018

@Meabo I've tested it in the browser and it looks like a bug. Thanks for your additional information!

@Meabo
Copy link

Meabo commented Dec 1, 2018

@nivida this is still a bug ? I can't reproduce the issue. Tested it in the browser : no error.

@nivida
Copy link
Contributor

nivida commented Dec 1, 2018

Yep tested it again no error too. Sorry for the confusion.

@nivida nivida closed this as completed Dec 1, 2018
@eyezick
Copy link
Contributor

eyezick commented Dec 2, 2018

I see this issue on node.js on an Ubuntu 18.04 instance with a local geth node

@ymonye
Copy link
Contributor

ymonye commented May 1, 2019

Ok, yeah I get the same problem where I'm not seeing any output while connecting to my local IPC node. Seems @eyezick is as well, dunno if he was able to resolve it since then.

I'm on Ubuntu 18.04, Geth v1.9.0-unstable, web3. 1.0.0-beta.53

Code:

const Web3 = require('web3');
const net = require('net');

const web3 = new Web3(
new Web3.providers.IpcProvider('/ssd_nvme_geth/mainnet/geth.ipc', net));

web3.eth.getBlockNumber().then(console.log);
web3.eth.getBlock('latest').then(console.log);

Results are completely empty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Addressing a bug
Projects
None yet
Development

No branches or pull requests

5 participants