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

Calling new Web3() without a provider breaks #2689

Closed
danoctavian opened this issue Apr 16, 2019 · 3 comments · Fixed by #2700
Closed

Calling new Web3() without a provider breaks #2689

danoctavian opened this issue Apr 16, 2019 · 3 comments · Fixed by #2700
Labels
Bug Addressing a bug
Projects

Comments

@danoctavian
Copy link

danoctavian commented Apr 16, 2019

Expected behavior

Running this should not crash.
const Web3 = require('Web3')
const web3 = new Web3()

Actual behavior

Crashes With

/Users/dan/qiibeework/qb-listener/node_modules/web3-providers/dist/web3-providers.cjs.js:49
      if (provider.sendPayload && provider.subscribe) {
                   ^

TypeError: Cannot read property 'sendPayload' of undefined
    at ProviderResolver.resolve (/Users/dan/qiibeework/qb-listener/node_modules/web3-providers/dist/web3-providers.cjs.js:49:20)
    at Web3.AbstractWeb3Module (/Users/dan/qiibeework/qb-listener/node_modules/web3-core/dist/web3-core.cjs.js:24:51)
    at new Web3 (/Users/dan/qiibeework/qb-listener/node_modules/Web3/dist/web3.cjs.js:30:68)
    at Object.<anonymous> (/Users/dan/qiibeework/qb-listener/junk.js:3:14)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3

Process finished with exit code 1```

### Versions 
* web3.js:
1.0.0-beta.52
* nodejs:
v8.15.0
@nivida
Copy link
Contributor

nivida commented Apr 16, 2019

Thanks for opening this issue! I‘ll fix and release it asap.

@nivida nivida added the Bug Addressing a bug label Apr 16, 2019
@nivida nivida added this to Accepted To Do's in 1.0 Apr 16, 2019
@nivida nivida changed the title calling new Web3() breaks Calling new Web3() without a provider breaks Apr 16, 2019
1.0 automation moved this from Accepted To Do's to Done Apr 17, 2019
@danoctavian
Copy link
Author

thanks @nivida

@nivida nivida mentioned this issue Apr 29, 2019
12 tasks
@raphael-arce
Copy link

raphael-arce commented May 2, 2019

I still get this crash (calling web3 without provider) in the 1.0.0-beta.53 version. Exactly the same code and error message as described by @danoctavian. Also getting this crash when trying to call web3 with a provider:

const Web3 = require('web3')
const web3 = new Web3(new Web3.providers.HttpProvider('https://ropsten.infura.io/v3/<mykey>'))

Perhaps I am doing something wrong?

Edit: My bad, the error actually came from somewhere else.

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.

3 participants