Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Calling new Web3() without a provider breaks #2689

@danoctavian

Description

@danoctavian

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugAddressing a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions