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

Uncaught TypeError: Cannot read property 'node' of undefined. #1986

Closed
MuhtasimTanmoy opened this issue Oct 8, 2018 · 15 comments
Closed

Uncaught TypeError: Cannot read property 'node' of undefined. #1986

MuhtasimTanmoy opened this issue Oct 8, 2018 · 15 comments
Labels
Needs Clarification Requires additional input

Comments

@MuhtasimTanmoy
Copy link

MuhtasimTanmoy commented Oct 8, 2018

Using web3 1.0.0 with infura. Everything was working fine but after version update it doesn't anymore.

@nivida
Copy link
Contributor

nivida commented Oct 9, 2018

@MuhtasimTanmoy Could you please add a code snippet?

@MuhtasimTanmoy
Copy link
Author

MuhtasimTanmoy commented Oct 9, 2018

I am working with web3.js in meteor.Need to call some methods in a smart contract.
console.log(web3.version);
gives 1.0.0-beta.36.
Any call to smart contract giving this error.

modules.js?hash=7271ca18827644f7480bc40a4802d23bc9cb95cd:68292 Uncaught TypeError: Cannot read property 'node' of undefined
    at new XMLHttpRequest (modules.js?hash=7271ca18827644f7480bc40a4802d23bc9cb95cd:68292)
    at HttpProvider._prepareRequest (modules.js?hash=7271ca18827644f7480bc40a4802d23bc9cb95cd:68092)
    at HttpProvider.send (modules.js?hash=7271ca18827644f7480bc40a4802d23bc9cb95cd:68121)
    at RequestManager.send (modules.js?hash=7271ca18827644f7480bc40a4802d23bc9cb95cd:32347)
    at sendRequest (modules.js?hash=7271ca18827644f7480bc40a4802d23bc9cb95cd:72820)
    at send (modules.js?hash=7271ca18827644f7480bc40a4802d23bc9cb95cd:72841)
    at Object._executeMethod (modules.js?hash=7271ca18827644f7480bc40a4802d23bc9cb95cd:76793)
    at App.test (SampleTest.jsx:20)
    at HTMLUnknownElement.callCallback (modules.js?hash=7271ca18827644f7480bc40a4802d23bc9cb95cd:9354)
    at Object.invokeGuardedCallbackDev (modules.js?hash=7271ca18827644f7480bc40a4802d23bc9cb95cd:9404)`

Also this undefined node points to

    `_this._userAgent = "Mozilla/5.0 (" + os.type() + " " + os.arch() + ") node.js/" + process.versions.node + " v8/" + process.versions.v8;`

in module.js

Was working fine lately.Not working after update.

`

@takahser
Copy link

@MuhtasimTanmoy which version are you using? I got the same error on ^1.0.0-beta.36.
Do you know which version it used to work with?

@takahser
Copy link

takahser commented Oct 21, 2018

So I tested some versions:

  • 1.0.0-beta.36 => fails
  • 1.0.0-beta.35 => fails
  • 1.0.0-beta.34 => works

So I rolled back to 1.0.0-beta.34 for now...
Guys, seriously, this version is half a year old. Why is it not working with the two most recent versions, why has it not been fixed yet? 🙄Sending transactions is the most basic thing you want to do on a cryptocurrency network, isn't it?

btw, this is my (typescript) code:

  send = async (wallet: Wallet, receiver: string, amount: number): Promise<any> => {
    const tx = {
      from: wallet.address,
      to: receiver,
      value: this.web3.utils.toHex(this.web3.utils.toWei(`${amount}`, 'ether')),
      gas: 200000,
    }

    const signedTx = await this.web3.eth.accounts.signTransaction(tx, wallet.privateKey);
    return this.web3.eth.sendSignedTransaction(signedTx.rawTransaction)
      .on('receipt', txReceipt => console.log('tx receipt received: ', txReceipt));
  }

@hedanto
Copy link

hedanto commented Oct 22, 2018

@MuhtasimTanmoy I got the same error on ^1.0.0-beta.36. Do you find a solution now?

2 similar comments
@hedanto
Copy link

hedanto commented Oct 22, 2018

@MuhtasimTanmoy I got the same error on ^1.0.0-beta.36. Do you find a solution now?

@hedanto
Copy link

hedanto commented Oct 22, 2018

@MuhtasimTanmoy I got the same error on ^1.0.0-beta.36. Do you find a solution now?

@johnpm-12
Copy link

I believe the problem is that web3 is not being bundled properly and the client is trying to use xhr2-cookies package instead of the browser's built-in XMLHttpRequest. xhr2-cookies package is for Node.js only, so it throws when process.versions.node is called, which doesn't exist in browsers.

0.20.7 uses xhr2-cookies, while 0.20.6 uses xhr2 package instead which gets bundled properly for the browser.
I have not looked into 1.0.0 but based on @takahser's comment, xhr2-cookies was probably introduced in beta 35.

@lucashenning
Copy link

This error occurs not only infura. I had the exact same error with beta.36 and Ganache. Rolling back to beta.34 solves this for now.

@nivida
Copy link
Contributor

nivida commented Nov 28, 2018

This should be fixed with the PR #2000

@nivida nivida added In Progress Currently being worked on and removed more information needed labels Nov 28, 2018
@d14na
Copy link

d14na commented Feb 27, 2019

receiving TypeError: Cannot read property 'node' of undefined, when attempting to web3.eth.getBlockNumber()

was using 1.0.0-beta.38; just updated to 1.0.0-beta.46, but still no luck


Edit: rolling back to 1.0.0-beta.34 fixes it for me as well.

kazurus pushed a commit to kazurus/endpass-connect that referenced this issue Mar 1, 2019
kazurus pushed a commit to endpass/endpass-connect that referenced this issue Mar 1, 2019
@agangdi
Copy link

agangdi commented Mar 7, 2019

process.versions.node

I fixed it by specify a value to process.versions.node
process.versions ={node: '11.2.0'}

@nivida nivida added Bug Addressing a bug and removed In Progress Currently being worked on labels Apr 2, 2019
@nivida nivida added Needs Clarification Requires additional input and removed Bug Addressing a bug labels Apr 15, 2019
@nivida
Copy link
Contributor

nivida commented Apr 16, 2019

This got fixed with the new HttpProvider. Feel free to open a new issue if there is still a problem.

@lowesyang
Copy link

lowesyang commented Sep 22, 2019

But i also have the same problems in web3 v1.2.1~

image

@katexue
Copy link

katexue commented Mar 31, 2021

process.versions.node

I fixed it by specify a value to process.versions.node
process.versions ={node: '11.2.0'}

I get the same problem with web3 v1.3.4, this fix resolved my issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Clarification Requires additional input
Projects
None yet
Development

No branches or pull requests

10 participants